hilbert 0.0.2700210 → 0.0.2700300
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/hilbert/parser.rb +1 -1
- data/lib/hilbert/version.rb +1 -1
- data/lib/hilbert/world/propositional_logic.rb +4 -0
- data/lib/hilbert/world.rb +5 -4
- data/test/interpreter/test_propositional_logic.rb +15 -2
- 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: 4cc36fbc59cc94de928020b2b2dac249d4e506df
|
4
|
+
data.tar.gz: 7477aad14d6b1aab2dfd326ea9a35cab85546b14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57add7b47e617dc4b20f0c4254e5a19581d8cd1edf653610c162d7cf69e0ca3a8e8971dfe9615621549b46c1c2e1eddc8e821ac5c777eba0772757db0cf5b412
|
7
|
+
data.tar.gz: 39682c6a58b60b81e788da0b0257400917d709974059ab3f428ed36d6efeba1c2ca0dc9d568dfead7bb872448d01b4d8869a2e49ebf4fc324437d9114452ae57
|
data/README.md
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/hilbert) [](https://travis-ci.org/gogotanaka/Hilbert) [](https://coveralls.io/r/gogotanaka/Hilbert?branch=master) [](https://codeclimate.com/github/gogotanaka/Hilbert) [](https://gemnasium.com/gogotanaka/Hilbert)
|
4
4
|
|
5
|
-
|
5
|
+
### Do you know the one best language in this world?
|
6
6
|
|
7
|
-
#### I believe mathematics(logic) is absolutely that
|
7
|
+
#### I believe mathematics (logic) is absolutely that language.
|
8
8
|
|
9
|
-
|
9
|
+
### How can we deal something as great as mathematics in a discrete world?
|
10
10
|
|
11
11
|
#### Hilbert is the answer.
|
12
12
|
|
@@ -22,9 +22,7 @@ Hilbert lets you have a sense of mathematics using a keyboard, the same as you w
|
|
22
22
|
|
23
23
|
## Demo
|
24
24
|
|
25
|
-
The code below is input and output for the Hilbert interpreter
|
26
|
-
|
27
|
-
(you can try it by `hilbert -i`)
|
25
|
+
The code below is input and output for the Hilbert interpreter. (You can try it with `hilbert -i`.)
|
28
26
|
|
29
27
|
### Logic
|
30
28
|
```coffeescript
|
@@ -35,8 +33,8 @@ Q -> R
|
|
35
33
|
|
36
34
|
P | Q # P or Q
|
37
35
|
~P # not P
|
38
|
-
Q? # Q is
|
39
|
-
=>
|
36
|
+
Q? # Q is TRUE?
|
37
|
+
=> TRUE
|
40
38
|
```
|
41
39
|
|
42
40
|
### Differentiate
|
@@ -109,10 +107,12 @@ f(1, 2)
|
|
109
107
|
|
110
108
|
## How to use
|
111
109
|
|
112
|
-
Install hilbert gem.
|
110
|
+
Install the `hilbert` gem.
|
113
111
|
|
114
112
|
$ gem install hilbert
|
115
113
|
|
114
|
+
Note to OS X Users: If the above `gem` command does not work with the stock version of Ruby (due to not being able to build a target indicated in the Makefile), then you will need to install a version of Ruby that includes the appropriate header files. Using [homebrew](http://brew.sh/) (`brew install ruby`) will suffice.
|
115
|
+
|
116
116
|
## Interpreter
|
117
117
|
|
118
118
|
$ hilbert -i
|
@@ -168,6 +168,6 @@ end
|
|
168
168
|
|
169
169
|
## Contributing
|
170
170
|
|
171
|
-
Any PRs or issues are welcome. (Please make to `develop` branch)
|
171
|
+
Any PRs or issues are welcome. (Please make them to [the `develop` branch](https://github.com/gogotanaka/Hilbert/tree/develop).)
|
172
172
|
|
173
|
-
You can become a
|
173
|
+
You can become a committer, even if you only commit once.
|
data/lib/hilbert/parser.rb
CHANGED
data/lib/hilbert/version.rb
CHANGED
data/lib/hilbert/world.rb
CHANGED
@@ -15,19 +15,20 @@ module Hilbert
|
|
15
15
|
# HOTFIX: we need to ..
|
16
16
|
return eval_rslt(logic_str, 'UNDEFINED') if @@propositions.empty?
|
17
17
|
logic = (@@propositions.inject(:*) >= to_rb_obj(logic_str))
|
18
|
-
str =
|
18
|
+
str = logic.dpll!.to_s
|
19
19
|
case str
|
20
20
|
when 'TRUE'
|
21
21
|
eval_rslt(logic_str, 'TRUE')
|
22
22
|
when 'FALSE'
|
23
23
|
eval_rslt(logic_str, 'FALSE')
|
24
24
|
else
|
25
|
-
|
25
|
+
logic = (@@propositions.inject(:*) >= (~to_rb_obj(logic_str)))
|
26
|
+
str = logic.dpll!.to_s
|
26
27
|
case str
|
27
28
|
when 'TRUE'
|
28
|
-
eval_rslt(logic_str, 'TRUE')
|
29
|
-
when 'FALSE'
|
30
29
|
eval_rslt(logic_str, 'FALSE')
|
30
|
+
when 'FALSE'
|
31
|
+
eval_rslt(logic_str, 'TRUE')
|
31
32
|
else
|
32
33
|
eval_rslt(logic_str, 'UNDEFINED')
|
33
34
|
end
|
@@ -24,12 +24,25 @@ class TestPropositionalLogic < TestInterpreterBase
|
|
24
24
|
assert_iq_equal('Evaluate: A is FALSE', 'A?')
|
25
25
|
end
|
26
26
|
|
27
|
+
def test_ex3
|
28
|
+
assert_iq_equal('Defined: A <-> B is TRUE', 'A <-> B')
|
29
|
+
assert_iq_equal('Defined: B is TRUE', 'B')
|
30
|
+
assert_iq_equal('Evaluate: A is TRUE', 'A?')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_ex4
|
34
|
+
assert_iq_equal('Evaluate: A is UNDEFINED', 'A ?')
|
35
|
+
assert_iq_equal('Defined: ~A is TRUE', '~A')
|
36
|
+
assert_iq_equal('Evaluate: A is FALSE', 'A ?')
|
37
|
+
end
|
38
|
+
|
39
|
+
|
27
40
|
def test_syllogisms
|
28
41
|
assert_iq_equal('Evaluate: A is UNDEFINED', 'A?')
|
29
|
-
assert_iq_equal('Evaluate: A -> C
|
42
|
+
assert_iq_equal('Evaluate: A -> C is UNDEFINED', 'A -> C ?')
|
30
43
|
assert_iq_equal('Defined: A -> B is TRUE', 'A -> B')
|
31
44
|
assert_iq_equal('Defined: B -> C is TRUE', 'B -> C')
|
32
|
-
assert_iq_equal('Evaluate: A -> C
|
45
|
+
assert_iq_equal('Evaluate: A -> C is TRUE', 'A -> C ?')
|
33
46
|
end
|
34
47
|
|
35
48
|
def test_paradox?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hilbert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2700300
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gogotanaka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dydx
|