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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0921177eea23a3eaec47a7c1f6f9a3885dad5759
4
- data.tar.gz: c0a30c5a79a38e4113096c97398cdaf390a02b8b
3
+ metadata.gz: 68b786dcea5db0011ebf3b7c4c8452ce7b1fd689
4
+ data.tar.gz: 8685d8a03576b28ba0601ca57a3a3dc22d3b5b9f
5
5
  SHA512:
6
- metadata.gz: 07164addc2bbf46d49af509e473e42daab575fa89a2494661d603a8b2f58389924b0b0f2753d0c09511e747d626636fb1da31a8f167b00461b360bb4a0a99288
7
- data.tar.gz: 7e2de12c7322b4a8a67301839dc185e277f7984afebf7984e848da188ed5eacacc2274cae63d1a03b28a934395f6a484be1767523774ba2669f863dcd2c0cf14
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
- * 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.
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 following are valid logical expression using the a,b and c variables:
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
- simplify_qm "a+ab"
54
+ simplify\_qm "a+ab"
52
55
  -> a
53
56
  * compute the conjunctive normal form of the expression a+ab:
54
- std_conj "a+ab"
57
+ std\_conj "a+ab"
55
58
  -> ab+a~b
56
59
  * compute the disjunctive normal form of the expression a+ab:
57
- std_conj "a+ab"
60
+ std\_dij "a+ab"
58
61
  -> (a+b)(a+~b)
59
62
  * compute the truth table of the expression a+ab:
60
- truth_tbl "a+ab"
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/logic_tools.
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
+
@@ -331,6 +331,7 @@ module LogicTools
331
331
  NodeVar.new(vars[0])
332
332
  end
333
333
  end
334
+ # print "sums = #{sums.to_s}\n"
334
335
  # Then the product
335
336
  # expr = NodeAnd.new(*sums).uniq
336
337
  if sums.size > 1 then
@@ -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
- dist << (right ? left.distribute(:and,right) : left)
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
@@ -1,3 +1,6 @@
1
- ~a~b~c~d+~a~bc+~ac~d+b~cd+a~b~c~d+a~bd
1
+ * ~a~b~c~d+~a~bc+~ac~d+b~cd+a~b~c~d+a~bd
2
2
  got: ~ac~d+~b~c~d+~bcd+b~cd
3
- good: ~b~c~d+b~cd+a~bd+~a~bc+~ac~d
3
+ good: ~ac~d+a~bd+~b~c~d+~bcd+b~cd
4
+ FIXED!
5
+
6
+
@@ -1,3 +1,3 @@
1
1
  module LogicTools
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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-04 00:00:00.000000000 Z
11
+ date: 2016-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler