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

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

Total release size: 52.9 MB

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

Download URL pyapproxmc-4.3.4-cp313-cp313-manylinux_2_34_x86_64.whl
Size 4.0 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
2f9547f81786473608facf8d146fc689f1cfedcea1d2adde8514369b4029e60b
BLAKE2b-256 checksum
How to use checksums
3f6ec0e8aa359ae675c3fd3eeace983c05760dc5b422103fb251e5a3bc2c44fa
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp313-cp313-manylinux_2_34_aarch64.whl
Size 3.6 MB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
0c3eb6377e9e82a45405f694aa80e34ef8fe7ccc23bf35690b0730eb4a1c4a9e
BLAKE2b-256 checksum
How to use checksums
78d101d54ea691135e0e2e9f3ddddf74ed676a06d43f568ee14797312774c6c4
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp313-cp313-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
48acbdd423d2512613a1920e95055bb2654d280f1ffab1cac19b0221933a03fc
BLAKE2b-256 checksum
How to use checksums
1f56657b1711658afe14899e638375a0e7fdda9042db7ffbfff208f2a5961534
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp312-cp312-manylinux_2_34_x86_64.whl
Size 4.0 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
1d577efdfded263c59f642582f248ce8d48a1c83aa52f331a4de207c827c7ede
BLAKE2b-256 checksum
How to use checksums
012f9ad7e050dcfb826f4b6abb708bd62e893a80a43add3d50308ed45ba6aba2
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp312-cp312-manylinux_2_34_aarch64.whl
Size 3.6 MB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
08290301201770da4bcfbe18ee797adedd2c01447edcdfa02fa5ff0a82a7ea03
BLAKE2b-256 checksum
How to use checksums
7fa068737f3d7443316f32a42c978c02e6c66dd566e2d28abafa9e1005b20503
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp312-cp312-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
372e82a8e2bcd8356a06296453f8fdf42a45a019020e9adbaeac6db1aae6ce66
BLAKE2b-256 checksum
How to use checksums
a8b374c42856952367f0fce0a86759f98d04e5524e58c9f4fdbdb7c2c6f909e0
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp311-cp311-manylinux_2_34_x86_64.whl
Size 4.0 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
2c32067f87ef49e9f2fed509ccc259b3362afe74ecf35a060e5a0c4a8d1175e0
BLAKE2b-256 checksum
How to use checksums
c0043173da6ce4fa71d13baae130688d3c822c01cc18666c7ba224efe21cc99c
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp311-cp311-manylinux_2_34_aarch64.whl
Size 3.6 MB
Tags CPython 3.11 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
6138c90d215f6bb8ab2fe21c37b462f2cd9ed37c6fd63c61009ec40c8e01b503
BLAKE2b-256 checksum
How to use checksums
130e1f9775bc88050d69115a605bf5818f4a4b6b37695d416f966028df8de9a6
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp311-cp311-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
298ab0a97c3a2c32c5b8a978a47b9f39a92956b9010b5fafeb5f6b1e0920b62c
BLAKE2b-256 checksum
How to use checksums
404237b123f124c99ecbe0d8131ed53cfefff13f95919e06aa76f5a103cab630
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp310-cp310-manylinux_2_34_x86_64.whl
Size 4.0 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
351592e244d7d5fa162f734feabcd2be08793c4ed87a2a6a0f73bc11b7d01777
BLAKE2b-256 checksum
How to use checksums
619cbba856555752cc717b3241b023df29ccf2e6f0893c3d3fa006b9cb551f21
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp310-cp310-manylinux_2_34_aarch64.whl
Size 3.6 MB
Tags CPython 3.10 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
5477fa8d349a9d39b6d679ea71f673b2265ae5acb171b814096513695610d7af
BLAKE2b-256 checksum
How to use checksums
065a7b3d49c60e6f17612010f12157b7fad89038761d427f70e179ff10800575
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp310-cp310-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f276bd47dcc96b288064a10edb2e0252f8653518862205677528ae96c848f40b
BLAKE2b-256 checksum
How to use checksums
0ad17b32494621b51e889d69823526eb56f54a73ffcd2f9ad3a7bb7ccae41f31
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp39-cp39-manylinux_2_34_x86_64.whl
Size 4.0 MB
Tags CPython 3.9 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
569676aeeebfc74d985e184d7c02f3946610e1e32ed509ea524ba4df6fa08dc0
BLAKE2b-256 checksum
How to use checksums
b95a3a16ffbc9420dae7155fe009f08a5aa73134a8dfd8d9310b65b6a554f8b2
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp39-cp39-manylinux_2_34_aarch64.whl
Size 3.6 MB
Tags CPython 3.9 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
10c33cd0ae170b2c610eb2722e13b92903658b440a0667caf4875c83c3463c1d
BLAKE2b-256 checksum
How to use checksums
64c86b696f83903f0a2d1d1d1fb62fd9a13a5222ee48de99b0ce6769c54ac16c
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 Sep 21, 2026.

Transparency log

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

Download URL pyapproxmc-4.3.4-cp39-cp39-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2f4e19b105fd9674bcfab1edfcf35fe9cc6a490ae286c6c443b1e0c228fe7955
BLAKE2b-256 checksum
How to use checksums
2c713d03057f2f7b938b0a864e07de5bfd722f65198ecc903fe781e4358da48f
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 Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

4.3.4 This release

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