CNF generator in DIMACS format. It produces common families of CNFs.
Clone or download

CNFgen formula generator and tools

Build Status Documentation Status

This repository provides the command

  • cnfgen formula generator;

and the following python scripts, designed to operate from/to dimacs CNFs:

  • cnfshuffle random shuffler;
  • cnftransform apply litfing or substitution;

You can get a brief help on how to use these tools by running <program_name> --help from the command line.

Run cnfgen --help to get a list of the implemented formula families. To get more specific information on one class of formula use the command

cnfgen <formula_type> --help

See the webpage of the project at


You can install CNFgen from Python Package Index, together with all its dependencies, typing either

easy_install [--user] cnfgen


pip install  [--user] cnfgen

Otherwise it is possible to install from source, assuming the requirements are already installed, using

python install [--user]

The --user option allows to install the package in the user home directory. If you do that please check that the target location for the command line utilities are in your $PATH.


Please contribute to the code by sending pull requests.

Copyright 2012, 2013, 2014, 2015, 2016, 2017, 2018 © Massimo Lauria (