logic_tools 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -13
- data/lib/logic_tools/logicsimplify.rb +1 -0
- data/lib/logic_tools/logictree.rb +6 -1
- data/lib/logic_tools/simplify_bug.txt +5 -2
- data/lib/logic_tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68b786dcea5db0011ebf3b7c4c8452ce7b1fd689
|
4
|
+
data.tar.gz: 8685d8a03576b28ba0601ca57a3a3dc22d3b5b9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e77ca46d2725b382528d08d9b180ea1864c3247c5c9114f4215be309333262dce348ba0d00b982034e5b26d9b1db96406991627c361bf05115c0815b0c049c5a
|
7
|
+
data.tar.gz: db8fa9b7b684f0597a9c50097c53893cfa8904cededad976f871c8b22d08dd6a197cd2fbca1a8b1a0ff53d04edd74ea6d0a96f72cbe8a928a4efc2762d523075
|
data/README.md
CHANGED
@@ -2,10 +2,14 @@
|
|
2
2
|
|
3
3
|
LogicTools is a set of command-line tools for processing logic expressions.
|
4
4
|
The tools include:
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
5
|
+
* simplify\_qm: for simplifying a logic expression.
|
6
|
+
* std\_conj: for computing the conjunctive normal form of a logic expression.
|
7
|
+
* std\_dij: for computing the disjunctive normal form a of logic expression.
|
8
|
+
* truth\_tbl: for generating the truth table of a logic expression.
|
9
|
+
|
10
|
+
## Disclaimer
|
11
|
+
|
12
|
+
There is still a nasty bug in the logic simplifying tool (simplify_qm) which makes it give a wrong result. Fortunately, it seems to happen in some rare cases only.
|
9
13
|
|
10
14
|
## Installation
|
11
15
|
|
@@ -26,21 +30,20 @@ Or install it yourself as:
|
|
26
30
|
## Usage
|
27
31
|
|
28
32
|
LogicTools is a command line-based set of tool. Each tool is used as follows:
|
29
|
-
tool "logical expression"
|
33
|
+
tool\_name "logical expression"
|
30
34
|
|
31
35
|
The logical expression is an expression where:
|
32
36
|
* a logical variable is represented by a single alphabetical character (hence there is in total 56 possible variables);
|
33
37
|
* a logical OR is represented by a '+' character;
|
34
38
|
* a logical AND is represented by a '.' character (but it can be omitted);
|
35
39
|
* a logical NOT is represented by a '~' or a '!' character;
|
36
|
-
* opening and closing parenthesis are represented by, respectively,
|
37
|
-
* '(' and ')' characters.
|
40
|
+
* opening and closing parenthesis are represented by, respectively, '(' and ')' characters.
|
38
41
|
|
39
42
|
Important notice:
|
40
43
|
* the priority among logical operators is as follows: NOT > AND > OR
|
41
44
|
* logical expressions must be put between quotes (the '"' character).
|
42
45
|
|
43
|
-
For instance the
|
46
|
+
For instance the followings are valid logical expression using the a,b and c variables:
|
44
47
|
"ab+ac"
|
45
48
|
"a.b.c"
|
46
49
|
"a+b+!c"
|
@@ -48,16 +51,16 @@ For instance the following are valid logical expression using the a,b and c vari
|
|
48
51
|
|
49
52
|
Finally, here are a few examples of LogicTool usage:
|
50
53
|
* simplifying the expression a+ab:
|
51
|
-
|
54
|
+
simplify\_qm "a+ab"
|
52
55
|
-> a
|
53
56
|
* compute the conjunctive normal form of the expression a+ab:
|
54
|
-
|
57
|
+
std\_conj "a+ab"
|
55
58
|
-> ab+a~b
|
56
59
|
* compute the disjunctive normal form of the expression a+ab:
|
57
|
-
|
60
|
+
std\_dij "a+ab"
|
58
61
|
-> (a+b)(a+~b)
|
59
62
|
* compute the truth table of the expression a+ab:
|
60
|
-
|
63
|
+
truth\_tbl "a+ab"
|
61
64
|
-> a b
|
62
65
|
0 0 0
|
63
66
|
0 1 0
|
@@ -72,10 +75,21 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
72
75
|
|
73
76
|
## Contributing
|
74
77
|
|
75
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/civol/
|
78
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/civol/logic\_tools.
|
76
79
|
|
77
80
|
|
78
81
|
## License
|
79
82
|
|
80
83
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
81
84
|
|
85
|
+
|
86
|
+
## To do
|
87
|
+
### High priority
|
88
|
+
* Fix the bug that makes simplify\_qm produce sometimes a wrong result.
|
89
|
+
* Downgrade the user interface: actually the interface can do much more than what is described in the documentation, but this is not really useful, so it should better to remove these features.
|
90
|
+
|
91
|
+
### Low priority
|
92
|
+
|
93
|
+
* Add a more efficient alternative command to simplify_qm, based on the Espresso algorithm for example.
|
94
|
+
|
95
|
+
|
@@ -611,7 +611,12 @@ module LogicTools
|
|
611
611
|
dist = []
|
612
612
|
nsons.each_slice(2) do |left,right|
|
613
613
|
# print "left=#{left}, right=#{right}\n"
|
614
|
-
|
614
|
+
if right then
|
615
|
+
dist << (left.op == :or ? left.distribute(:and,right) :
|
616
|
+
right.distribute(:and,left))
|
617
|
+
else
|
618
|
+
dist << left
|
619
|
+
end
|
615
620
|
end
|
616
621
|
# print "dist=#{dist}\n"
|
617
622
|
nsons = dist
|
data/lib/logic_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logic_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11
|
11
|
+
date: 2016-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|