hilbert 0.0.2700110 → 0.0.2700210
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hilbert/version.rb +1 -1
- data/lib/hilbert/world.rb +12 -3
- data/test/interpreter/test_propositional_logic.rb +7 -1
- data/test/world/test_prop_logic.rb +3 -0
- 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: b5504e360e4fc6ff8787b6afb21fb32b73e1bf53
|
4
|
+
data.tar.gz: 3500645d88a619fc8e78962a003374deab4813bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ed780a081d43467792c2386114e150f381a45bcc252b1498598530af5522446b3a6e47897af1921de19873c026f2cf6e048f39035b41d9fb6a887498693925c
|
7
|
+
data.tar.gz: 74f09536225b22137482d27d8b3de55326e06b81a27e9f24274cdb8dc12a516ca35b39e0fb2e23af2ccecd6d799234a53bd7cf6c415a222fd60abe1f9db17485
|
data/lib/hilbert/version.rb
CHANGED
data/lib/hilbert/world.rb
CHANGED
@@ -12,16 +12,25 @@ module Hilbert
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def impl(logic_str)
|
15
|
-
# HOTFIX:
|
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
19
|
case str
|
19
20
|
when 'TRUE'
|
20
21
|
eval_rslt(logic_str, 'TRUE')
|
21
22
|
when 'FALSE'
|
22
23
|
eval_rslt(logic_str, 'FALSE')
|
23
24
|
else
|
24
|
-
|
25
|
+
str = (!!!!!!!(@@propositions.inject(:*) * logic)).to_s
|
26
|
+
case str
|
27
|
+
when 'TRUE'
|
28
|
+
eval_rslt(logic_str, 'TRUE')
|
29
|
+
when 'FALSE'
|
30
|
+
eval_rslt(logic_str, 'FALSE')
|
31
|
+
else
|
32
|
+
eval_rslt(logic_str, 'UNDEFINED')
|
33
|
+
end
|
25
34
|
end
|
26
35
|
end
|
27
36
|
|
@@ -10,7 +10,7 @@ class TestPropositionalLogic < TestInterpreterBase
|
|
10
10
|
assert_equal(output, Hilbert::Iq.execute(input))
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def test_ex1
|
14
14
|
assert_iq_equal('Defined: A is TRUE', 'A')
|
15
15
|
assert_iq_equal('Evaluate: A is TRUE', 'A?')
|
16
16
|
assert_iq_equal('Evaluate: B is UNDEFINED', 'B?')
|
@@ -18,6 +18,12 @@ class TestPropositionalLogic < TestInterpreterBase
|
|
18
18
|
assert_iq_equal('Evaluate: B is TRUE', 'B?')
|
19
19
|
end
|
20
20
|
|
21
|
+
def test_ex2
|
22
|
+
assert_iq_equal('Evaluate: A is UNDEFINED', 'A?')
|
23
|
+
assert_iq_equal('Defined: ~A is TRUE', '~A')
|
24
|
+
assert_iq_equal('Evaluate: A is FALSE', 'A?')
|
25
|
+
end
|
26
|
+
|
21
27
|
def test_syllogisms
|
22
28
|
assert_iq_equal('Evaluate: A is UNDEFINED', 'A?')
|
23
29
|
assert_iq_equal('Evaluate: A -> C is UNDEFINED', 'A -> C ?')
|
@@ -51,6 +51,7 @@ class TestPropLogic < MiniTest::Unit::TestCase
|
|
51
51
|
assert_to_s("((Q|P)&(R|P))", $p + ($q * $r))
|
52
52
|
assert_to_s("(P&Q&R)", $p * ($q * $r))
|
53
53
|
assert_to_s("(P&(~P|Q))", $p * ($p >= $q))
|
54
|
+
assert_to_s("P", (~$p >= $p))
|
54
55
|
end
|
55
56
|
|
56
57
|
def test_tautology
|
@@ -59,9 +60,11 @@ class TestPropLogic < MiniTest::Unit::TestCase
|
|
59
60
|
assert_to_s("TRUE", (($p >= $q) * ($q >= $r)) >= ($p >= $r))
|
60
61
|
assert_to_s("TRUE", (~$p * ($p + $q)) >= ($q))
|
61
62
|
assert_to_s("TRUE", (($p >= $q) * ($q >= $r) * $p) >= ($r))
|
63
|
+
assert_to_s("TRUE", ($p * ~$p) >= $r)
|
62
64
|
end
|
63
65
|
|
64
66
|
def test_no_tautology
|
65
67
|
assert_to_s("FALSE", $p * $q * ~$p)
|
68
|
+
assert_to_s("FALSE", ~$p * (~$p >= $p))
|
66
69
|
end
|
67
70
|
end
|
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.2700210
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dydx
|