GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • python-nnf
  • Installing
  • Module reference
  • Command line interface
  • Caveats

This view

  • Original page
  • New address

GeezerVison is showing python-nnf.readthedocs.io — Welcome to python-nnf’s documentation! — python-nnf documentation

Welcome to python-nnf’s documentation!¶

python-nnf is a package for working with logical sentences written in the negation normal form.

Contents:

  • Installing
  • Module reference
    • Module contents
    • Submodules
    • nnf.operators module
    • nnf.dimacs module
    • nnf.dsharp module
    • nnf.amc module
    • nnf.tseitin module
    • nnf.kissat module
    • nnf.pysat module
  • Command line interface
    • SAT solving
    • Sentence summary
    • Visualizing sentences
  • Caveats
    • Node duplication
    • Decomposability and determinism
    • Other duplication inefficiencies

Introduction¶

Sentences are made up of nodes. To start with, define some variables:

>>> from nnf import Var
>>> A, B, C = Var('A'), Var('B'), Var('C')

Then, if you want to write the sentence “A or B”:

>>> from nnf import Or
>>> sentence = Or({A, B})
>>> sentence = A | B  # alternative syntax

Or “B and not C”:

>>> from nnf import And
>>> sentence = And({B, ~C})
>>> sentence = B & ~C

Of course you can nest these, for more interesting sentences:

>>> sentence = Or({And({A, B}), And({~B, C})})

You can ask queries, and perform transformations:

>>> sentence.decomposable()
True
>>> sentence.smooth()
False
>>> list(sentence.models())
[{'A': True, 'B': True, 'C': True}, {'A': True, 'B': False, ...
>>> new = sentence.condition({'B': True})
>>> new
Or({And({A, true}), And({false, C})})
>>> list(new.models())
[{'A': True, 'C': True}, {'A': True, 'C': False}]
>>> new.simplify()
A

Indices and tables¶

  • Index
  • Module Index
  • Search Page
©2019, Jan Verbeek. | Powered by Sphinx 1.8.6 & Alabaster 0.7.12 | Page source
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.