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.1.0.tar.gz (20.0 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.1.0-cp313-cp313-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.13Windows x86-64

pybipe-1.1.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.1.0-cp312-cp312-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pybipe-1.1.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.1.0-cp311-cp311-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pybipe-1.1.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.1.0-cp310-cp310-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.10Windows x86-64

pybipe-1.1.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.1.0-cp39-cp39-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.9Windows x86-64

pybipe-1.1.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.1.0.tar.gz.

File metadata

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

File hashes

Hashes for pybipe-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e2d2430bf01c2d7c4f1b0fa2baab466668f7a966259667feaa432f121d17aede
MD5 a9586306f9e14c1f2f318401047c5ba1
BLAKE2b-256 2d7907950f0823671f4e0f114a72d72c9e5b33d6a554fa305e67eb5e0ff8cb53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybipe-1.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.1 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.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 db0b080678a2f4ac2b52ef13b5b65edfd719f36459984e0d5bd6911108b3c4f8
MD5 16a592f376c690f24020eb91998c14f2
BLAKE2b-256 d747194243b0dbe2ddbd3399625fecc5f02be67c8fe064a1ee332887bbc91fd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybipe-1.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cabee0a1f0c27839d4a3c73cf46a1ce3c28c47d68639d84ca1384cb4c4aec79b
MD5 9e0b6d736a92475c6352387ffcb25f78
BLAKE2b-256 67248bcaa1e145c8a9b6738b805876cfac4ef0bb051a9340d116d2889a37cd85

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybipe-1.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.1 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.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 900d2347d9a8d4d2b9068a558607caf75a161e70bf2792fae026c7bab31a71f2
MD5 f4196c1f6dc1cd61ee7a5a09d9b25786
BLAKE2b-256 1772c378f30c53f441279bf674a81501c4b418d05ab4b881ab6705b16fe24fef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybipe-1.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3234137119cc4ac5250f0ad9021b4ebd4a1feb9cf275f4b22b2cf9807d657a3d
MD5 73e6c743cdc72007ef6392e35561ac96
BLAKE2b-256 1b62c501150fdfeb05191f11a2eb3ae719b90fdabd2a2ed69d1ff7ab6e6ba32f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybipe-1.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 4.1 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.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 335cb35b6d158484351b5e19018cc55279dc06bc87e753b72836d644ad03350d
MD5 b7a359633c953acfe4f616d1de277475
BLAKE2b-256 6da1e10c3fff1d4283cd213246b66f3396b65cdd9ab4e9fc7a2be76c637a7d5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybipe-1.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 936e14f4d94052c57c8ae9d21d68ca175e2f8f1ce999ee321746e34221d1664b
MD5 e5349f462093747f0b39783ace886e1c
BLAKE2b-256 6ded718b2eb9da9e62054ac7f8c039b119135a4152b16253daef5d644282b910

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybipe-1.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 4.1 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.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2c1b522b3e7e8a133d1acb229b02ffcdc03a75d075a8da25076b12a94279809a
MD5 2a1be09e7d250042544b014d7db26030
BLAKE2b-256 6e9c788af0303dca183c1aaa3a6961161d44b84a2b915f1828bef2d1220f6207

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybipe-1.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 adb95eae172858ee24c0bcdfbd82c8f082c7ebc97fd2d053a4121979e63f908f
MD5 5b4c373302138e7280dfe590fbb6bf12
BLAKE2b-256 a4cf411345722ae27599382c9e086637a00d447ab40c8196a88e0bd46451350d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybipe-1.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.1 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.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1a29d623303c2206d6f581a3fe0eec3c5956adcf47efbc283a33812b5d22b84b
MD5 6a922a5fb66e1c6a9abae0078167b4e2
BLAKE2b-256 8206cf1ae81f3fb52df71baf5d0fee933704edd8e8615b802106dbdd780bd820

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybipe-1.1.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 de52e4bffd6ec48285ca3dedae94b88aaab58d28b9fb253ef3cf9a5db733e753
MD5 70cfaa8618bfc64989d5176c5744f082
BLAKE2b-256 4b8f2f6f440f3a91d04e39606ce3aff2323d0ee982a217afcc028795b9850210

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