LogicTools is a ruby library and a set of command-line tools for processing logic expressions.
Currently, the tools can produce the standard conjunctive and disjunctive forms of a logic expression, generate its truth table or simplify it.
- GitHub repository
- Installation throw RubyGem:
gem install logic_tools
LogicTools is a set of command-line tools for processing logic expressions.
The tools include:
simplify_qmsimplifies a logic expression using the Quine-Mc Cluskey algorithm.
simplify_essimplifies a logic expression using the ESPRESSO algorithm.
std_conjcomputes the conjunctive normal form of a logic expression.
std_dijcomputes the disjunctive normal form a of logic expression.
truth_tblgenerates the truth table of a logic expression.
complementcomputes the complement of a logic expression.
is_tautologytells if a logic expression is a tautology or not.
Each tool is used as follows:
tool_name "logical expression"
The “logical expression” is an expression where:
- a logical variable is represented by a single alphabetical character (hence there is in total 56 possible variables), or a string of alphabetical characters enclosed by curly brackets;
- a logical OR is represented by a
- a logical AND is represented by a
'.'character (but it can be omitted);
- a logical NOT is represented by a
- opening and closing parenthesis are represented by, respectively,
- The priority among logical operators is as follows: NOT > AND > OR.
- Logical expressions must be put between quotes (the
For instance the followings are valid logical expression using the
- Simplifying the expression a+ab:
- Compute the conjunctive normal form of the expression a+ab:
- Compute the disjunctive normal form of the expression a+ab:
- Compute the truth table of the expression a+ab:
0 0 0
0 1 0
1 0 1
1 1 1
- Update the code of
simplify_qmso that it uses the optimized