Skip to main content

Checks DRUP proofs against DIMACS source. Extracted from verified Why3 code.

Project description

Verified DRUP Proof Checker

As the title suggests, a verified implementation of a checker for propositional unsatisfiability proofs in the DRUP format that is produced by several solvers. The core of the checker is written in Why3, which is extracted to OCaml, compiled natively, and exported as a C library with Python bindings.

  • The checker does not support DRAT proofs, but this may be added in the future.
  • The current implementation is not optimized, and will be considerably slower than DRAT-trim on large proofs.
  • Accordingly, the frontend does not accept proofs in binary format.
  • There is currently no CLI, but one can be written as needed in a few minutes using the API described below.

The verification can be checked by running src/librupchecker/rup_pure.mlw in Why3. Most of the verification conditions complete with the Auto level 0 tactic, and the rest either with a few levels of splitting followed by Auto 0 or Auto 1, or simply with Auto 2. It was developed using Why3 1.5.1, Alt-Ergo 2.4.0, Z3 4.8.6, and CVC4 1.8. Verification has not been attempted with earlier versions of Why3 or the provers.

Installation

If you use a recent Linux distribution on x86_64, you should be able to install the compiled wheel from PyPI:

$ pip install drup

Otherwise, pip will attempt to extract and compile the library, which means that you need to have OCaml (>= 4.12), Why3 (>= 1.5.1), and Dune (>=2.9.3) installed. The most straightforward way to install these is to use opam, which is available in most package systems, and then install Why3 and Dune (a sufficiently recent version of OCaml should already be installed with Opam):

$ opam install why3 dune

If you do not intend to check the verification of the library or develop it further, then you do not need to install Why3's IDE or any of the solvers that it supports.

Once OCaml and Why3 are installed, you can use the pip command above to compile and install the library from source.

Usage

If you do not intend to use the Python bindings, then you will find the C shared object in the Python package directory:

$(PYTHON_PATH)/site-packages/rup/librupchecker.{so|dll}

The C library exposes two wrappers around the core checker:

int check_from_file(const char *dimacs_path, const char *drup_path);
int check_from_strings(const char *dimacs, const char *drup);

Before either of these can be called, the library must be initialized with a call to do_startup passing the current argv, which calls caml_startup:

int do_startup(char **argv);

Either function returns 0 if the proof is valid, and -1 otherwise.

The Python bindings expose these same functions, but will call do_startup automatically automatically when the package is imported, so there is no need to call it manually. If the arguments given to the Python bindings cannot be opened (in the case of files) or parsed, then they raise ValueError.

As described, the package is straightforward to use:

import drup

cnf = """
p cnf 4 8
 1  2 -3 0
-1 -2  3 0
 2  3 -4 0
-2 -3  4 0
 1  3  4 0
-1 -3 -4 0
-1  2  4 0
 1 -2 -4 0
"""

pf = """
1 2 0
1 0
2 0
0
"""

if drup.check_from_strings(cnf, pf) == 0:
    print("Valid")
else:
    print("Invalid")

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

drup-1.0.0.tar.gz (238.6 kB view details)

Uploaded Source

Built Distribution

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

drup-1.0.0-cp39-cp39-manylinux_2_35_x86_64.whl (240.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.35+ x86-64

File details

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

File metadata

  • Download URL: drup-1.0.0.tar.gz
  • Upload date:
  • Size: 238.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for drup-1.0.0.tar.gz
Algorithm Hash digest
SHA256 12047cc06696417a48da7e3e9a1f030d4f48e4434d017f5b3b0b01b7338eedff
MD5 250ca8fbd4825238690a126488f22329
BLAKE2b-256 8d03e11ea3ad7ab3e3b50a688fe1b39b077bc71e0b679783ce66cd8a02f3f485

See more details on using hashes here.

File details

Details for the file drup-1.0.0-cp39-cp39-manylinux_2_35_x86_64.whl.

File metadata

  • Download URL: drup-1.0.0-cp39-cp39-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 240.9 kB
  • Tags: CPython 3.9, manylinux: glibc 2.35+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for drup-1.0.0-cp39-cp39-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 14e1f474e2f5f05cbbe4dc0df0d346c5343149886504c1033c8aafc8b8d7707d
MD5 0a2cfe7c8eb7ec9d344d1a381d45c91e
BLAKE2b-256 ab68290d4c3ca554a45663411de2c6e76ed6e9898ddb82681697123bc9dd1f6b

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