tables

Tools for working with truth tables.

tables.truth_table module

Implementation of a truth table.

class tt.tables.truth_table.TruthTable(expr, fill_all=True, ordering=None)

Bases: object

A class representing a truth table.

expr

The BooleanExpression object or a string from which to create the BooleanExpression object represented by this truth table.

ordering

List[str], optional

An optional list of symbol names in the passed expression, specifying the order in which they should appear in the truth table (from left to right). If omitted, the ordering of the symbols will be consistent with the symbol’s first occurrence in the passed expression.

results

List[bool]

A list of int s representing the resultant evaluations for each combination of possible inputs.

Raises:
  • DuplicateSymbolError
  • ExtraSymbolError
  • MissingSymbolError
fill(**kwargs)

Fill the table with results, based on values specified by kwargs.

Parameters:

**kwargs – Filter which entries in the table are filled by specifying symbol values through the keyword args.

Raises:
  • ExtraSymbolError
  • InvalidBooleanValueError
  • MissingSymbolError