hilbert 0.0.2700210 → 0.0.2700300

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: b5504e360e4fc6ff8787b6afb21fb32b73e1bf53
4
- data.tar.gz: 3500645d88a619fc8e78962a003374deab4813bd
3
+ metadata.gz: 4cc36fbc59cc94de928020b2b2dac249d4e506df
4
+ data.tar.gz: 7477aad14d6b1aab2dfd326ea9a35cab85546b14
5
5
  SHA512:
6
- metadata.gz: 8ed780a081d43467792c2386114e150f381a45bcc252b1498598530af5522446b3a6e47897af1921de19873c026f2cf6e048f39035b41d9fb6a887498693925c
7
- data.tar.gz: 74f09536225b22137482d27d8b3de55326e06b81a27e9f24274cdb8dc12a516ca35b39e0fb2e23af2ccecd6d799234a53bd7cf6c415a222fd60abe1f9db17485
6
+ metadata.gz: 57add7b47e617dc4b20f0c4254e5a19581d8cd1edf653610c162d7cf69e0ca3a8e8971dfe9615621549b46c1c2e1eddc8e821ac5c777eba0772757db0cf5b412
7
+ data.tar.gz: 39682c6a58b60b81e788da0b0257400917d709974059ab3f428ed36d6efeba1c2ca0dc9d568dfead7bb872448d01b4d8869a2e49ebf4fc324437d9114452ae57
data/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/hilbert.svg)](http://badge.fury.io/rb/hilbert) [![Build Status](https://travis-ci.org/gogotanaka/Hilbert.svg?branch=master)](https://travis-ci.org/gogotanaka/Hilbert) [![Coverage Status](https://coveralls.io/repos/gogotanaka/Hilbert/badge.png?branch=master)](https://coveralls.io/r/gogotanaka/Hilbert?branch=master) [![Code Climate](https://codeclimate.com/github/gogotanaka/Hilbert/badges/gpa.svg)](https://codeclimate.com/github/gogotanaka/Hilbert) [![Dependency Status](https://gemnasium.com/gogotanaka/Hilbert.svg)](https://gemnasium.com/gogotanaka/Hilbert)
4
4
 
5
- ## Do you know the one best language in this world?
5
+ ### Do you know the one best language in this world?
6
6
 
7
- #### I believe mathematics(logic) is absolutely that one.
7
+ #### I believe mathematics (logic) is absolutely that language.
8
8
 
9
- ## How can we deal something as great as mathematics in a discrete world?
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 TURE?
39
- => TURE
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 commiter, even if you only commit once.
173
+ You can become a committer, even if you only commit once.
@@ -37,7 +37,7 @@ module Hilbert
37
37
  lexed.parsed!(rslt, $2)
38
38
 
39
39
  when /:(EVALOGIC)(\d+)/
40
- value = lexed.get_value($1).delete("?\n")
40
+ value = lexed.get_value($1).rm(/ *\?/).delete("\n")
41
41
  rslt = $world.impl value
42
42
  lexed.parsed!(rslt, $2)
43
43
 
@@ -1,3 +1,3 @@
1
1
  module Hilbert
2
- VERSION = '0.0.2700210'
2
+ VERSION = '0.0.2700300'
3
3
  end
@@ -71,6 +71,10 @@ module Hilbert
71
71
  def include?(p)
72
72
  false
73
73
  end
74
+
75
+ def dpll!
76
+ !!!!!!!!!!!!self
77
+ end
74
78
  end
75
79
 
76
80
  module Base; include Operator; include Utils end
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 = (!!!!!!!logic).to_s
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
- str = (!!!!!!!(@@propositions.inject(:*) * logic)).to_s
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 is UNDEFINED', '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 is TRUE', '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.2700210
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-18 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dydx