boolean_logic¶
- are_equivalent(this: str, other: str) bool ¶
uses minimize_espresso to compute whether this and other are equivalent.
- are_mutually_exclusive(this: str, other: str) bool ¶
uses minimize_espresso to compute whether A and B are mutually exclusive
- implies(this: str, other: str) bool ¶
uses minimize_espresso to compute whether this implies other.
- minimize_espresso(expression: str, fname_out: Optional[str] = None, merge: bool = False, equiv: bool = False, exact: bool = False, reduce: bool = False) str ¶
Tries to minimize a given boolean expression utilizing the heuristic minimization algorithm espresso and eqntott for its input preparation. Resulting expression is saved in file if filename for output is specified. The argument expression may be either the name of the input file containing the boolean expression or the string representing the expression itself. The input expression may not contain the following words: False, FALSE, True, TRUE, Zero, ZERO, One, ONE.
- arguments:
expression: name of file containing the expression or string contents of file
fname_out: name of the file to write the output to
merge: performs distance-1 merge on input, useful if very large
equiv: identifies equivalent output variables
exact: performs exact minimization algorithm, guarantees minimum number of product terms and heuristically minimizes number of literals, potentially expensive
reduce: eqntott tries to reduce the size of the truth table by merging minterms
- returns:
minimized_expression: the minimized expression
example:
>>> minimize_espresso("bool_function.txt", "minimized_function.txt" ) >>> minimize_espresso("var = (a & b) | a;") >>> minimize_espresso("var = 1") >>> minimize_espresso("(a & b) | a")