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.0

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.0
File
pyapproxmc-4.4.0-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
pyapproxmc-4.4.0-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details
pyapproxmc-4.4.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
pyapproxmc-4.4.0-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
pyapproxmc-4.4.0-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details
pyapproxmc-4.4.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
pyapproxmc-4.4.0-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
pyapproxmc-4.4.0-cp311-cp311-manylinux_2_34_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ ARM64 Details
pyapproxmc-4.4.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
pyapproxmc-4.4.0-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
pyapproxmc-4.4.0-cp310-cp310-manylinux_2_34_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ ARM64 Details
pyapproxmc-4.4.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
pyapproxmc-4.4.0-cp39-cp39-manylinux_2_34_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ x86-64 Details
pyapproxmc-4.4.0-cp39-cp39-manylinux_2_34_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ ARM64 Details
pyapproxmc-4.4.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details

Total release size: 54.9 MB

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

Download URL pyapproxmc-4.4.0-cp313-cp313-manylinux_2_34_x86_64.whl
Size 4.2 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
469de6d8929e114b392e8d9c44c67347f146c7cad4eeb959de858deb8f0d29f2
BLAKE2b-256 checksum
How to use checksums
e63a08da0bee196ed20be4eb40ce18f38ae84d4fd30fb1635a2bfcb760c24835
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-cp313-cp313-manylinux_2_34_aarch64.whl
Size 3.8 MB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
3fb58b3b6240b6dcb29292234b31fdc05e17fe680fcff8568fc0ac07a2655536
BLAKE2b-256 checksum
How to use checksums
243b909dfe241750fd1e89f5d3f37a74d384cdfec2d7f8d5c1f9975f5caf8d7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-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
264121f8aa9da4b4a76f18b3384cccf8fa3a264af2efa5fbd8c590d6ab15df27
BLAKE2b-256 checksum
How to use checksums
2d627d289d91364f78cf665da01336433a2317371032bd349d4d73c2356c5383
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-cp312-cp312-manylinux_2_34_x86_64.whl
Size 4.2 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
d7f7ca641debeaacc45992d97962c842f5d71cc25e50539d570552509b9e9615
BLAKE2b-256 checksum
How to use checksums
4eb0b5f53e3af917492d0f502a4471276275f551730d5dc01a5a632b55531053
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-cp312-cp312-manylinux_2_34_aarch64.whl
Size 3.8 MB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
6817330bd8227337b33b2c72865e2fd5899b4602a2651a48a273f2727f1b895f
BLAKE2b-256 checksum
How to use checksums
ed863680220ac627455728ff9e5ac6ccfecc91a7c746ae744674246f1e02f549
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-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
b2b38a2f7d71a9005e934b27ccd4a9aeb880a9fd0f117f3c1a1eb8c2cc93a2f7
BLAKE2b-256 checksum
How to use checksums
64b3a2fba16058b0a304be626329508c7e56fd561210ca649516e6bd2c8a18a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-cp311-cp311-manylinux_2_34_x86_64.whl
Size 4.2 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
dc6a569e5687f0b161b73521abdb85f9bf4f234039b7991d3e77485fc75a9e05
BLAKE2b-256 checksum
How to use checksums
e8e141f68623021116bca7abab31c6e500517b03f79bd33a2171c607f90f9b45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-cp311-cp311-manylinux_2_34_aarch64.whl
Size 3.8 MB
Tags CPython 3.11 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
4a178c3b49cdce3b47059b9a391adf30f68164641722be6fc0740e7941598674
BLAKE2b-256 checksum
How to use checksums
8bc5a1f91543625ff122934a79d6e2d1add15c9571c647ed463765812f379a37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-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
2f76836f4fa57a7402e3b0f90ba273e3baf4b6115fde54ddb0191215407f29f3
BLAKE2b-256 checksum
How to use checksums
bc43739bea46f54eda34e307f0a46c1e12e404853907cbbe7f5c6f4e58b1cfb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-cp310-cp310-manylinux_2_34_x86_64.whl
Size 4.2 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
05a37402b88505b78b704e774b694f7e2346d398b71d5b1b5503b66895e14565
BLAKE2b-256 checksum
How to use checksums
faead0dedda80bf0ab0609fd32d8f24312c579dbb5185dd0668e09fdd7b1f287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-cp310-cp310-manylinux_2_34_aarch64.whl
Size 3.8 MB
Tags CPython 3.10 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
0b30fd25d28318e1e12b442e11f5659ba2db7d9e3f7b15eefa5aac6f588952e4
BLAKE2b-256 checksum
How to use checksums
541511803c3052c84fe925b18dde2a91860727fe8e36e6e7def09f75577a88ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-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
a241ecff3e521f0e05dc2f816d8e66d47d5da74ada66868f306b09425dc21e41
BLAKE2b-256 checksum
How to use checksums
7deda6d2b216abb87a5c1f777d688e0d745aa22f14ec23c5c862fb30b3f6d94a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

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

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-cp39-cp39-manylinux_2_34_aarch64.whl
Size 3.8 MB
Tags CPython 3.9 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
c30ba5b998ea6e1bb80d0ff29bdfd5b8a0244d99d9ddf2cb4ed9a799e36bd7ea
BLAKE2b-256 checksum
How to use checksums
c0e38639efbfb0a36d36c786b483521341a77d2bf569f8a7960985deb86a08dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

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

Download URL pyapproxmc-4.4.0-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
c1d17548aef2397e5b825e51e21e87ab4da9b6c18767186e7f122cbb10b9b388
BLAKE2b-256 checksum
How to use checksums
4441731e14edc5b72ec85be9394fba4041516a8ce847d1980f294164747b53b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

4.4.0 This release

15 release files

4.3.4

15 release files

4.3.3

15 release files

4.3.2

15 release files

4.3.1

15 release files

4.1.18

9 release files

4.1.17

9 release files

4.1.16

9 release files

4.1.15

9 release files

4.1.14

9 release files

4.1.11

6 release files

4.1.9

6 release files

4.1.8

1 release file

4.1.7

1 release file

4.1.5

1 release file

4.1.4

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

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