An example to demostrate the usage of make boolean function.ΒΆ

from __future__ import print_function
from BinPy.algorithms.makebooleanfunction import *
# Usage of make_boolean() function
logical_expression, gate_form = make_boolean(['A', 'B', 'C'], [1, 4, 7], minterms=True)
# Print the logical function
print(logical_expression)
((A AND (NOT B) AND (NOT C)) OR (A AND B AND C) OR ((NOT A) AND (NOT B) AND C))
# Print the gate form
print(gate_form)
OR(AND(A, NOT(B), NOT(C)), AND(A, B, C), AND(NOT(A), NOT(B), C))
# Another example
logical_expression, gate_form = make_boolean(['A', 'B', 'C', 'D'], [1, 4, 7, 0], maxterms=True)
# Print the logical function
print(logical_expression)
(D OR ((NOT A) AND B) OR (A AND (NOT B) AND C) OR (B AND (NOT C)))
# Print the gate form
print(gate_form)
OR(D, AND(NOT(A), B), AND(A, NOT(B), C), AND(B, NOT(C)))