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.
Resources:
- GitHub repository
- Installation throw RubyGem:
gem install logic_tools
Documentation:
LogicTools is a set of command-line tools for processing logic expressions.
The tools include:
simplify_qm
simplifies a logic expression using the Quine-Mc Cluskey algorithm.
simplify_es
simplifies a logic expression using the ESPRESSO algorithm.
std_conj
computes the conjunctive normal form of a logic expression.
std_dij
computes the disjunctive normal form a of logic expression.
truth_tbl
generates the truth table of a logic expression.
complement
computes the complement of a logic expression.
is_tautology
tells 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
'+'
character; - a logical AND is represented by a
'.'
character (but it can be omitted); - a logical NOT is represented by a
'~'
or a'!'
character; - opening and closing parenthesis are represented by, respectively,
'('
and')'
characters.
Important notices:
- The priority among logical operators is as follows: NOT > AND > OR.
- Logical expressions must be put between quotes (the
'"'
character).
For instance the followings are valid logical expression using the a
,b
and c
variables:
1 2 3 4 |
"ab+ac" "a.b.c" "a+b+!c" "a~(b+~c)" |
Examples:
- Simplifying the expression a+ab:
simplify_qm "a+ab"Result: a
- Compute the conjunctive normal form of the expression a+ab:
std_conj "a+ab"Result: ab+a~b
- Compute the disjunctive normal form of the expression a+ab:
std_dij "a+ab"Result: (a+b)(a+~b)
- Compute the truth table of the expression a+ab:
truth_tbl "a+ab"Result:
1 2 3 4 5 |
a b 0 0 0 0 1 0 1 0 1 1 1 1 |
To do
Low priority
- Update the code of
simplify_qm
so that it uses the optimizedLogicTool::Cover class
.