Skip to main content

pyapproxmc: Python bindings to ApproxMC

Python bindings to ApproxMC, an approximate model counter with PAC (Probably Approximately Correct) guarantees. ApproxMC counts the number of satisfying assignments of CNF formulas.

Installing

pip install pyapproxmc

Building from source

# Install build tools
pip install scikit-build-core build

# Clone the repository
git clone --recurse-submodules https://github.com/meelgroup/approxmc
cd approxmc

# Build and install into a virtual environment
python -m venv .venv && source .venv/bin/activate
pip install .

The build system uses scikit-build-core and CMake. All C++ dependencies (CryptoMiniSat, Arjun, and their sub-dependencies) are fetched and built automatically by CMake during the pip install step. The only system library required is GMP:

  • Linux: sudo apt-get install libgmp-dev (or dnf install gmp-devel)
  • macOS: brew install gmp

Usage

import pyapproxmc

c = pyapproxmc.Counter()
c.add_clause([1, 2, 3])
c.add_clause([3, 20])
count = c.count()
print("Approximate count is: %d*2**%d" % (count[0], count[1]))

count() may only be called once per Counter instance; create a new Counter if you need to count a different formula.

The above prints Approximate count is: 11*2**16. Since the largest variable in the clauses is 20, the formula has at most 2**20 models; the two clauses restrict this to approximately 11*2**16 ≈ 720896 models.

Counting over a projection set

Pass a projection set (sampling set) to count() to count models projected onto a subset of variables:

import pyapproxmc

c = pyapproxmc.Counter()
c.add_clause([1, 2, 3])
c.add_clause([3, 20])
count = c.count(range(1, 10))
print("Approximate count is: %d*2**%d" % (count[0], count[1]))

This prints Approximate count is: 7*2**6, the approximate count projected over variables 1–9.

Adding clauses from arrays

For performance-critical code, multiple clauses can be added in one call via add_clauses() with a flat, zero-terminated array.array. This uses the buffer protocol and avoids per-element Python overhead:

import pyapproxmc
from array import array

c = pyapproxmc.Counter()
# Clauses [1,2,3] and [3,20], each terminated by 0
c.add_clauses(array('i', [1, 2, 3, 0, 3, 20, 0]))
count = c.count()

Note: add_clause() (singular) also accepts any iterable including arrays, but iterates element by element and does not use the buffer protocol.

Counter constructor parameters

Parameter Default Description
seed 1 Random seed for reproducibility
verbosity 0 Output verbosity (0 = silent)
epsilon 0.8 Tolerance: how approximate the count is
delta 0.2 Confidence: probability the count is within tolerance

Example:

c = pyapproxmc.Counter(seed=42, epsilon=0.5, delta=0.1)

Version

import pyapproxmc
print(pyapproxmc.__version__)

Metadata

Release files for pyapproxmc 4.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyapproxmc 4.4.1
File Actions
pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details for pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_x86_64.whl
pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details for pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_aarch64.whl
pyapproxmc-4.4.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for pyapproxmc-4.4.1-cp313-cp313-macosx_11_0_arm64.whl
pyapproxmc-4.4.1-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details for pyapproxmc-4.4.1-cp312-cp312-manylinux_2_34_x86_64.whl
pyapproxmc-4.4.1-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details for pyapproxmc-4.4.1-cp312-cp312-manylinux_2_34_aarch64.whl
pyapproxmc-4.4.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for pyapproxmc-4.4.1-cp312-cp312-macosx_11_0_arm64.whl
pyapproxmc-4.4.1-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details for pyapproxmc-4.4.1-cp311-cp311-manylinux_2_34_x86_64.whl
pyapproxmc-4.4.1-cp311-cp311-manylinux_2_34_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ ARM64 Details for pyapproxmc-4.4.1-cp311-cp311-manylinux_2_34_aarch64.whl
pyapproxmc-4.4.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for pyapproxmc-4.4.1-cp311-cp311-macosx_11_0_arm64.whl
pyapproxmc-4.4.1-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details for pyapproxmc-4.4.1-cp310-cp310-manylinux_2_34_x86_64.whl
pyapproxmc-4.4.1-cp310-cp310-manylinux_2_34_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ ARM64 Details for pyapproxmc-4.4.1-cp310-cp310-manylinux_2_34_aarch64.whl
pyapproxmc-4.4.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for pyapproxmc-4.4.1-cp310-cp310-macosx_11_0_arm64.whl
pyapproxmc-4.4.1-cp39-cp39-manylinux_2_34_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ x86-64 Details for pyapproxmc-4.4.1-cp39-cp39-manylinux_2_34_x86_64.whl
pyapproxmc-4.4.1-cp39-cp39-manylinux_2_34_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ ARM64 Details for pyapproxmc-4.4.1-cp39-cp39-manylinux_2_34_aarch64.whl
pyapproxmc-4.4.1-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details for pyapproxmc-4.4.1-cp39-cp39-macosx_11_0_arm64.whl

Total release size: 56.7 MB

Release files / pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_x86_64.whl
Size 4.4 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
d4043d3fd8ed7bd1d37aa865a1615e1562eb1a74309e430a0d38b301ff79444a
BLAKE2b-256 checksum
How to use checksums
7819eb7f04d8b65174cf3bca4c110ff10ea54725d935d080e2f77a4bf528d431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_aarch64.whl

Download URL pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_aarch64.whl
Size 4.0 MB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
f204e95a44e69909cb94f4e51cadf4d569723b19bac899fe0448c311117a608c
BLAKE2b-256 checksum
How to use checksums
f709dd093c89fcd24e053c3473ae9a40715f338123d5aa4527be4865349ff2e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL pyapproxmc-4.4.1-cp313-cp313-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c692a04b6a6a7641db5e3b5905388a3659570c02cb1d4fd177ec5453f6f33795
BLAKE2b-256 checksum
How to use checksums
033635f63862151caa131064076cfd60a0403c752c2f0fe6c73aa2f37bf3c263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL pyapproxmc-4.4.1-cp312-cp312-manylinux_2_34_x86_64.whl
Size 4.4 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
da5b7bd5ff7ea9847aac83d74dd7ed13115ed316170e2425596f06f4838db4f5
BLAKE2b-256 checksum
How to use checksums
2b9330bb882c7d0f7988b507b1e595b4b97987153906adf29c9d5da2b28d768c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp312-cp312-manylinux_2_34_aarch64.whl

Download URL pyapproxmc-4.4.1-cp312-cp312-manylinux_2_34_aarch64.whl
Size 4.0 MB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
9c6604b9489d30bc73fb027fa72c02282fed766019025b263e201f6c65beaf5f
BLAKE2b-256 checksum
How to use checksums
8d07641593045b5ce12179668aea93deced47d8db61eb484f625a739b67c080b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL pyapproxmc-4.4.1-cp312-cp312-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
128f997deebcbba48bb2efef4f93673ed11f1db51d1ded3b04251407ef686bce
BLAKE2b-256 checksum
How to use checksums
1a9b835c43c91504cd97ceda7b0a4328f51a921e0ff507ef0f79b39cce090876
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL pyapproxmc-4.4.1-cp311-cp311-manylinux_2_34_x86_64.whl
Size 4.4 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
8d0a20783da0d426ad8e5430d3257918a7ef2748302a56f414afe85cd1d5dab3
BLAKE2b-256 checksum
How to use checksums
878224fa2187819ed54e8b4f8825cb6b97ab018703f750a4dc0cd73b4e9d805f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp311-cp311-manylinux_2_34_aarch64.whl

Download URL pyapproxmc-4.4.1-cp311-cp311-manylinux_2_34_aarch64.whl
Size 4.0 MB
Tags CPython 3.11 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
2aeb3b3e17c5d325af7d9a73220d9b9925c96c02706a55151dae133edb91193c
BLAKE2b-256 checksum
How to use checksums
d086a67b2d592d6b5a6c99863cac90d96f4dfc43e0173b0c3de8167a627aa2c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL pyapproxmc-4.4.1-cp311-cp311-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3b4fb890519809e86b8d36eea4e644447202fa33dbc62cfe0d1baf522c438e26
BLAKE2b-256 checksum
How to use checksums
f6786d91bcc6b8f2609abc55d27e23a967bb2e2ba6e2a921c829f0a6b5fa0632
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL pyapproxmc-4.4.1-cp310-cp310-manylinux_2_34_x86_64.whl
Size 4.4 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
69b124c30038fc3c8b4b9710157ec5a495556c6878b549eda4484f79740d2138
BLAKE2b-256 checksum
How to use checksums
54d39792be03feff93ca7af16368a3e5c6b296c3d5fce4508ee5f25512f48b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp310-cp310-manylinux_2_34_aarch64.whl

Download URL pyapproxmc-4.4.1-cp310-cp310-manylinux_2_34_aarch64.whl
Size 4.0 MB
Tags CPython 3.10 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
c40db19f92f52a9291b7986556ffc38093842bbeb1526a27f64514010006efb2
BLAKE2b-256 checksum
How to use checksums
7cd4927297d174a2d9bcb794dc649a2c7fd185964bc49a084aa556cdea73854c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL pyapproxmc-4.4.1-cp310-cp310-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
59b716d9ab02ad8e7280f10cff3b70447102fd43c7a4734afee0560b389ccc48
BLAKE2b-256 checksum
How to use checksums
495fb595e234e1e8cb12cd664f196ae547dd292e544f4966be848d2209c3e3a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp39-cp39-manylinux_2_34_x86_64.whl

Download URL pyapproxmc-4.4.1-cp39-cp39-manylinux_2_34_x86_64.whl
Size 4.4 MB
Tags CPython 3.9 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
9ffb5598ec985c54686d52da920d5e31b47083161d9929bdfce5ebdd57e38ac9
BLAKE2b-256 checksum
How to use checksums
a3902df854493857cd37a5684b52692f0ab8ff27bea249e360f559acd086b0cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp39-cp39-manylinux_2_34_aarch64.whl

Download URL pyapproxmc-4.4.1-cp39-cp39-manylinux_2_34_aarch64.whl
Size 4.0 MB
Tags CPython 3.9 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
159691a577899fec84b735352b6cbdd3b40eea0006c0fd3537b0d7e5566a0c9c
BLAKE2b-256 checksum
How to use checksums
2632dc7d59debc616813ee5d37ad16716b0a5645feb5fb2cfbf73b8e3d10c1fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / pyapproxmc-4.4.1-cp39-cp39-macosx_11_0_arm64.whl

Download URL pyapproxmc-4.4.1-cp39-cp39-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6bf839623e65fc3324f018cfa94bb298eae2c0bb967d3f7bc5c355e3acb58296
BLAKE2b-256 checksum
How to use checksums
2c909159faa628635462248bbeb888e80b7bab67ba5891e99d044eb57189c985
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for pyapproxmc 4.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 15 files in this release have been uploaded with provenance metadata.

Select from 15 files

Attestation for pyapproxmc-4.4.1-cp313-cp313-manylinux_2_34_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.4.1 This release

15 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page