Skip to main content

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

Project description

A 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 many 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 also supports RAT clauses, so DRAT proofs are accepted.
  • The current implementation is not optimized, and will be considerably slower than DRAT-trim on large proofs (see performance below).
  • Accordingly, the frontend does not accept proofs in binary format.

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, you need to have OCaml (>= 4.12), Ctypes (>=0.20), 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, make sure that Python build is installed:

$ pip install build

Then, clone this repository, build, and install the package:

$ git clone https://github.com/cmu-transparency/verified_rup.git
$ cd verified_rup
$ python -m build
$ pip install dist/*.whl

Usage

Command line interface

The package provides a command line interface for checking proofs stored in files:

$ drup --help
usage: drup [-h] [-d] [-v] dimacs drup

Checks DRUP & DRAT proofs against DIMACS source. Returns 0 if the proof is valid, -1 if not, or a negative error code if the input is invalid.

positional arguments:
  dimacs            Path to a DIMACS CNF formula
  drup              Path to a DRUP/DRAT proof

optional arguments:
  -h, --help        show this help message and exit
  -d, --derivation  Check each step, ignore absence of empty clause
  -v, --verbose     Print detailed information about failed checks

For more information visit https://github.com/cmu-transparency/verified_rup

As a Python module

See the documentation for details of the API. The primary function is drup.check_proof, or alternatively, drup.check_derivation to check each step of the proof, ignoring the absence of an empty clause).

def check_proof(formula : Cnf, proof : Proof, verbose : bool = False) -> CheckerResult:
  """Check a sequence of RUP and RAT clauses against a CNF. Inputs are Python iterables
  of clauses, where each clause is an iterable of signed Python ints.

  Args:
    formula (Cnf): Cnf as an iterable of clauses.
    proof (Proof): Iterable of RUP or RAT clauses.
    verbose (bool, optional): Return detailed information
      if the check fails. Defaults to False.

  Returns:
    CheckerResult: CheckerResult struct representing the result of the check.
  
  Raises:
    ValueError: If the formula or proof cannot be formatted.
  """

This takes a CNF and Proof as an iterable of iterables of signed integers, and returns a CheckerResult.

class CheckerResult:

  '''
  Result of a proof check.

  Attributes:

    outcome (`Outcome`): The outcome of the check. If the check
      succeeded, this will be Outcome.VALID. If the check failed,
      this will be Outcome.INVALID.

    steps (`Optional[Cnf]`): Completed proof steps prior to an invalid step, 
      if the proof was invalid.

    rup_info (`Optional[RupInfo]`): Information on a failed RUP check,
      if the proof was invalid.

    rat_info (`Optional[RatInfo]`): Information on a failed RAT check,
      if the proof was invalid. The RAT clause in this object will
      be the same as the RUP clause in `rup_info`.
  '''

There are corresponding convenience functions check_proof_from_strings and check_proof_from_files, similarly for check_derivation.

Performance

At present, the implementation of RUP checking is not optimized, and drop lines are ignored. Unit propagation does not take advantage of watched literals, and does not use mutable data structures. Nonetheless, the performance compares well to that of DRAT-trim on small proofs (<200 variables, a few hundred clauses).

We measure this on random unsatisfiable instances generated by the procedure described in [1]. To evaluate the performance of DRAT-trim without the overhead of creating and tearing down a new process for each instance, we compiled it into a library with the same check_from_strings interface as the C library, and called it using ctypes. In the table below, each configuration is run on 10,000 instances, with proofs generated by Glucose 4.

# vars # clauses (avg) pf len (avg) drup (sec, avg) drat-trim (sec, avg)
25 147.7 7.3 0.001 0.085
50 280.5 14.2 0.006 0.179
75 413.5 26.3 0.022 0.217
100 548.2 40.6 0.068 0.172
150 811.8 102.7 0.407 0.326
200 1079.5 227.9 1.916 0.292

References

[1] Daniel Selsam, Matthew Lamm, Benedikt Bünz, Percy Liang, Leonardo de Moura, David L. Dill. Learning a SAT Solver from Single-Bit Supervision. International Conference on Learning Representations (ICLR), 2019.

Acknowledgements

Many thanks to Frank Pfenning, Joseph Reeves, and Marijn Huele for the ongoing insightful discussions that led to this project.

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.2.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distributions

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

drup-1.2.0-cp310-cp310-manylinux_2_17_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

drup-1.2.0-cp39-cp39-manylinux_2_17_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

drup-1.2.0-cp38-cp38-manylinux_2_17_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

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

File hashes

Hashes for drup-1.2.0.tar.gz
Algorithm Hash digest
SHA256 d088f0954ce41b6e0cf5ed260d345a6aa1aeae875614dec547a19897a7fb19fe
MD5 22f860d06187812bf35c1c0f9c72cc17
BLAKE2b-256 97bd9b571091644b02d551a79627c55b6007ddffa0a85674ec768ec09846fcd6

See more details on using hashes here.

File details

Details for the file drup-1.2.0-cp310-cp310-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drup-1.2.0-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 61a072cf1c5114e13c0f808b0446ff46559a804301a60b1cb0e25e986d2eca76
MD5 6042b1fd1effed493f0b4197339ca8fb
BLAKE2b-256 03665e4330fd85a2d551a2f227f50573d3b1a827d25cbb24bfbc3cf851d2a69c

See more details on using hashes here.

File details

Details for the file drup-1.2.0-cp39-cp39-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drup-1.2.0-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9a23a9101d2afd163538d632527cb847912a404a2efc04364567da8f32222d33
MD5 8168faa4555a5317100a70a37cc968ee
BLAKE2b-256 9138d89ffcca3ed08dd54532782f7ed6ea10520d52cb54e368082e6607dcb796

See more details on using hashes here.

File details

Details for the file drup-1.2.0-cp38-cp38-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drup-1.2.0-cp38-cp38-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 5e018c30784d278bf6cc4346ea37549fa356d060e1e7b4e4ea0bf4c9eef7dfab
MD5 3c95c8b6bed168d65e47596f1fd378b2
BLAKE2b-256 9d8f25a52719294881389bd7d1430d8637d44d6226e3bb0c5ec955fe01afa852

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