Skip to main content

Python bindings for the bipe SAT preprocessor

Project description

pybipe

Python bindings for bipe, a state-of-the-art C++20 SAT preprocessing library. pybipe supports bipartitioning (input/output variable identification via Padoa definability), bounded variable elimination (BVE), backbone derivation, equivalence substitution, and DAC extraction, with full option configuration and DIMACS parsing. Built with nanobind and scikit-build-core.


🚀 Users Guide

1. Installation

Install from PyPI:

pip install pybipe

Or install from the GitLab Package Registry:

pip install pybipe --extra-index-url https://gitlab.univ-artois.fr/api/v4/projects/24773/packages/pypi/simple

2. Usage Examples

2.1 Basic SAT Preprocessing

You can run preprocessing on raw Python clause structures (list of lists of DIMACS 1-based literals):

from pybipe import PreprocManager, OptionPreproc, PreprocMethod, run_preproc

# Define input CNF formula
nb_vars = 3
clauses = [
    [1, 2],
    [-2, 3],
    [-1, -3]
]
projected = [1, 2, 3]  # Candidate variables for bipartitioning

# Configure options
opts = OptionPreproc()
opts.autoConfig = True  # Enable automatic density-based tuning

# Run preprocessing
mgr = PreprocManager()
out_vars, out_clauses, out_projected = mgr.run(
    nbVar=nb_vars,
    clauses=clauses,
    projected=projected,
    options=opts
)

print(f"Preprocessed: nbVar={out_vars}, {len(out_clauses)} clauses remaining.")

Or using the simplified single-function interface:

out_vars, out_clauses, out_projected = run_preproc(
    nbVar=3,
    clauses=[[1, 2], [-2, 3]],
    projected=[1, 2, 3],
    options=opts
)

2.2 Parsing DIMACS Files

You can parse DIMACS CNF files directly into a Python ParsedProblem object:

from pybipe import ParserDimacs

parser = ParserDimacs()
problem = parser.parse_dimacs("path/to/formula.cnf")

print(f"Variables: {problem.nbVar}, Clauses: {len(problem.clauses)}")
print("Projected variables:", problem.projected)

# Re-print as DIMACS string
print(problem.display())

2.3 Solver Options & Custom Configurations

pybipe exposes native C++ optree configuration groups (OptionPreproc, OptionEliminator, OptionBipartition, OptionBackbone, OptionDac, OptionReducer) with property accessors and docstrings:

from pybipe import OptionPreproc, PreprocMethod, load_options_from_dict, dump_options_to_dict

opt = OptionPreproc()

# 1. Modify top-level preprocessor options
opt.timeout = 600
opt.autoConfig = False
opt.optionPreprocMethod = PreprocMethod.SHARP_EQUIV

# 2. Modify nested eliminator options
opt.optionEliminator.growthBudget = 1.5
opt.optionEliminator.oracleVivif = True
opt.optionEliminator.bva = True

# 3. Serialize options to/from Python Dictionaries
config_dict = dump_options_to_dict(opt)
opt_restored = load_options_from_dict(config_dict)

🛠️ Developers Guide

1. Requirements

Before building locally, ensure the following dependencies are installed:

  • C++20 compatible compiler (GCC >= 10, Clang >= 10)
  • CMake (>= 3.15)
  • Zlib development headers (zlib1g-dev / zlib-devel)
  • Python >= 3.8

2. Local Build Pipeline

To compile the C++ extension module and deploy it into your Python environment:

# Clone pybipe
git clone https://gitlab.univ-artois.fr/logical/pybipe.git
cd pybipe

# Build and run tests
./build.sh --test

Alternatively, install in editable mode:

pip install -e .

3. Automatic Code Generation

If bipe option headers or data structures change, re-run the code generation scripts:

python3 scripts/generate_binding_hpp.py /path/to/bipe
python3 scripts/generate_bindings.py /path/to/bipe
python3 scripts/generate_runner_bindings.py /path/to/bipe

4. Running the Test Suite

LD_PRELOAD=$(gcc -print-file-name=libstdc++.so.6) PYTHONPATH=. python3 tests/test_options.py
LD_PRELOAD=$(gcc -print-file-name=libstdc++.so.6) PYTHONPATH=. python3 tests/test_preproc.py
LD_PRELOAD=$(gcc -print-file-name=libstdc++.so.6) PYTHONPATH=. python3 tests/test_parser.py

5. GitLab CI/CD Pipeline

The repository includes a multi-stage .gitlab-ci.yml pipeline:

  • Build Stage: Runs cibuildwheel to build standalone Linux and Windows wheels for Python 3.8-3.13, plus an sdist package.
  • Deploy Stage: Triggered on pushing Git tags, publishing wheel packages to the GitLab PyPI Package Registry or PyPI using twine.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybipe-1.0.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pybipe-1.0.0-cp313-cp313-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.13Windows x86-64

pybipe-1.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pybipe-1.0.0-cp312-cp312-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.12Windows x86-64

pybipe-1.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pybipe-1.0.0-cp311-cp311-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.11Windows x86-64

pybipe-1.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pybipe-1.0.0-cp310-cp310-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.10Windows x86-64

pybipe-1.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pybipe-1.0.0-cp39-cp39-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.9Windows x86-64

pybipe-1.0.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pybipe-1.0.0.tar.gz.

File metadata

  • Download URL: pybipe-1.0.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pybipe-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2ddb8b3d717a4dee7f7f9e81994815dfe433cf36ddf6817898068ba465dec448
MD5 f633fe4dfd51e2be7d3ba97faafa467c
BLAKE2b-256 42dd99071593622e5b99d2edf97fd4887a34674d29d97361999a8969f9d043d8

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pybipe-1.0.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pybipe-1.0.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f2a54868cbeaf99852048a71861b7bd843f7f056639be66e0781612420fb4331
MD5 38985f4d274660947fe558abf3af4801
BLAKE2b-256 e596ff58d24e680ecc21caf10c5cfec42e9d8ac9408a1c201f18f85586ba4c44

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pybipe-1.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 91d12acaf96d8497f4450e93ae9de2df3394ea9a427911b9f754476d9b8bb460
MD5 ed753b15fe96941e5dffb1092fdf440c
BLAKE2b-256 13a6288ba6c1795db6ecbae5634d966e94dba95b4f95e0f91c406e97682d8c65

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pybipe-1.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pybipe-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ae8c77c350af13d7f345f56e38e4f911943e5c2fcd6fe7f26fee6a31b5a34dc2
MD5 312af7b525659912f0576c4b79500e8f
BLAKE2b-256 270a63685b7e47b19209bf2a4fbd0c33bd271bcf5bfb7563aec66d57966beebb

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pybipe-1.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 95715ed9714d60d385abb350ebaa02df695e443eec36c248404e2f4149dab678
MD5 73affdf8c3c0c2dab9ea26e2daf0f582
BLAKE2b-256 a7be48db4ba99221d4e4121cf2ea85167b5cff092940c7f04e4a087d457098a6

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pybipe-1.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pybipe-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 10e7af111b5655e7a70e149d2aa346524137dc5c111e1cabcbb7ed81c2ed03cc
MD5 6767c612791b0f779172b5c88f613273
BLAKE2b-256 2bd26343bd9088c02e1159edc86c20ab7babc6a8b659ff28baf2d5ef107b4302

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pybipe-1.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1a267d6a745f5b3ae578f3191d41bc83e9acc09f8dcff6c7a2a1e2ca10102fcb
MD5 bfa29ecaf89088135fbcab780b208aea
BLAKE2b-256 f4cf4ddcc252a6fc0e04ded1eb59dbb7fb6391e7f0e44c74842447f015024ff2

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pybipe-1.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pybipe-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a02d5d601a030d47f4eec32d80117bbaffb834663e1ab16e4f54f98edc3f2cf7
MD5 32112a425d0ed754db9f1f41b85ffad9
BLAKE2b-256 0aa9f698c8d9a11c7ffc7ed1ddd796e7dd57de538a38bbf500c09f00f6ef8046

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pybipe-1.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2711d43bb2ff6b864351e1ec15d1d4280a2d6be1cdb2886c73df1ce98d7caa27
MD5 740713ec1fe5c264241c757718efd577
BLAKE2b-256 d1ade3cd2a308a688a9d74af773ed5edf0f465ea80fbf0a8fed562a00cb50a97

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pybipe-1.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pybipe-1.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 47b5a49ba7e65d31a6a2a9f1f23bd8f9bce4c4e9bc58a4eafdb9c253158726fb
MD5 2a36b1323b1636df5733f2aebadba703
BLAKE2b-256 e0b5832bcd587d812f8088958ed29f7731bc2bd0645b5a1242439d1a4afa35f4

See more details on using hashes here.

File details

Details for the file pybipe-1.0.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pybipe-1.0.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 479100c1313b4674509284bba00ae97a6ef3557597376af12d93c73197b04a15
MD5 c03162182955f9ea9b0e2acd4f7a4300
BLAKE2b-256 0a541daeb294fae087d07d9ecf2c09c5e14bb199da28e72940a02bc1289e8c4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page