Skip to main content

Python library to convert between AIGER and CNF

Project description


Python library to convert between AIGER and CNF

Build Status codecov PyPI version License: MIT

Table of Contents


If you just need to use aiger_cnf, you can just run:

$ pip install py-aiger-cnf

For developers, note that this project uses the poetry python package/dependency management tool. Please familarize yourself with it and then run:

$ poetry install


The primary entry point for using aiger_cnf is the aig2cnf function which, unsurprisingly, maps AIG objects to CNF objects.

import aiger
from aiger_cnf import aig2cnf

x, y, z = map(aiger.atom, ('x', 'y', 'z'))
expr = (x & y) | ~z
cnf = aig2cnf(

Note that this library also supports aiger wrapper libraries so long as they export a .aig attribute. Thus, could also write:

cnf = aig2cnf(expr)

The CNF object is a NamedTuple with the following three fields:

  1. clauses: A list of tuples of ints, e.g., [(1,2,3), (-1, 2)]. Each integer represents a variable's id, with the sign indicating the polarity of the variable.
  2. input2lit: A bidict from input names to variable ids.
  3. output2lit: A bidict from output names to variable ids.

Project details

Download files

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

Files for py-aiger-cnf, version 5.0.0
Filename, size File type Python version Upload date Hashes
Filename, size py_aiger_cnf-5.0.0-py3-none-any.whl (5.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size py-aiger-cnf-5.0.0.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page