rubylog 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.hu.rb +58 -0
- data/README.rdoc +248 -89
- data/Rakefile +6 -1
- data/VERSION +1 -1
- data/bin/rubylog +18 -0
- data/examples/dcg.rb +35 -0
- data/examples/dcg2.rb +42 -0
- data/examples/enumerators.rb +30 -0
- data/examples/factorial.rb +9 -8
- data/examples/hanoi.rb +24 -0
- data/examples/hello.rb +11 -5
- data/examples/parsing.rb +27 -0
- data/examples/primitives.rb +24 -0
- data/examples/theory.rb +22 -10
- data/lib/rubylog/builtins/default.rb +10 -0
- data/lib/rubylog/builtins/file_system.rb +15 -0
- data/lib/rubylog/builtins/logic.rb +109 -0
- data/lib/rubylog/builtins/reflection.rb +94 -0
- data/lib/rubylog/builtins/term.rb +47 -0
- data/lib/rubylog/dsl/array_splat.rb +25 -0
- data/lib/rubylog/dsl/primitives.rb +17 -0
- data/lib/rubylog/dsl/thats.rb +22 -0
- data/lib/rubylog/dsl/variables.rb +30 -0
- data/lib/rubylog/dsl.rb +35 -17
- data/lib/rubylog/errors.rb +19 -1
- data/lib/rubylog/interfaces/assertable.rb +16 -0
- data/lib/rubylog/interfaces/callable.rb +18 -0
- data/lib/rubylog/interfaces/composite_term.rb +47 -0
- data/lib/rubylog/interfaces/predicate.rb +8 -0
- data/lib/rubylog/interfaces/procedure.rb +60 -0
- data/lib/rubylog/interfaces/term.rb +41 -0
- data/lib/rubylog/mixins/array.rb +118 -0
- data/lib/{class.rb → rubylog/mixins/class.rb} +2 -2
- data/lib/rubylog/mixins/hash.rb +8 -0
- data/lib/rubylog/mixins/kernel.rb +5 -0
- data/lib/rubylog/mixins/method.rb +3 -0
- data/lib/rubylog/mixins/object.rb +8 -0
- data/lib/rubylog/mixins/proc.rb +37 -0
- data/lib/rubylog/mixins/string.rb +104 -0
- data/lib/rubylog/mixins/symbol.rb +44 -0
- data/lib/rubylog/simple_procedure.rb +8 -0
- data/lib/rubylog/{clause.rb → structure.rb} +32 -31
- data/lib/rubylog/theory.rb +368 -79
- data/lib/rubylog/variable.rb +102 -23
- data/lib/rubylog.rb +33 -25
- data/logic/builtins/file_system_logic.rb +23 -0
- data/logic/builtins/reflection_logic.rb +40 -0
- data/logic/dereference_logic.rb +23 -0
- data/logic/directory_structure_logic.rb +19 -0
- data/logic/dsl_logic.rb +29 -0
- data/logic/errors_logic.rb +9 -0
- data/logic/guard_logic.rb +115 -0
- data/logic/list_logic.rb +55 -0
- data/logic/map_logic.rb +15 -0
- data/logic/multitheory.rb +23 -0
- data/logic/recursion_logic.rb +12 -0
- data/logic/string_logic.rb +41 -0
- data/logic/thats_logic.rb +51 -0
- data/logic/variable_logic.rb +24 -0
- data/rubylog.gemspec +85 -46
- data/spec/bartak_guide_spec.rb +57 -62
- data/spec/builtins/all_spec.rb +99 -0
- data/spec/builtins/and_spec.rb +22 -0
- data/spec/builtins/array_spec.rb +16 -0
- data/spec/builtins/branch_or_spec.rb +27 -0
- data/spec/builtins/cut_spec.rb +44 -0
- data/spec/builtins/fail_spec.rb +5 -0
- data/spec/builtins/false_spec.rb +5 -0
- data/spec/builtins/in_spec.rb +38 -0
- data/spec/builtins/is_false_spec.rb +12 -0
- data/spec/builtins/is_spec.rb +26 -0
- data/spec/builtins/matches_spec.rb +23 -0
- data/spec/builtins/or_spec.rb +22 -0
- data/spec/{rubylog/builtins → builtins}/splits_to.rb +0 -0
- data/spec/builtins/then_spec.rb +27 -0
- data/spec/builtins/true_spec.rb +5 -0
- data/spec/clause_spec.rb +82 -0
- data/spec/compilation_spec.rb +61 -0
- data/spec/custom_classes_spec.rb +43 -0
- data/spec/dereference.rb +10 -0
- data/spec/{inriasuite.rb → inriasuite_spec.rb} +2 -9
- data/spec/queries_spec.rb +150 -0
- data/spec/recursion_spec.rb +4 -4
- data/spec/ruby_code_spec.rb +52 -0
- data/spec/rules_spec.rb +97 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/theory_spec.rb +28 -0
- data/spec/unification_spec.rb +84 -0
- data/spec/variable_spec.rb +26 -0
- metadata +153 -180
- data/examples/4queens.rb +0 -10
- data/examples/calculation.rb +0 -12
- data/examples/concepts.rb +0 -46
- data/examples/fp.rb +0 -56
- data/examples/historia_de_espana.rb +0 -31
- data/examples/idea.rb +0 -143
- data/examples/lists.rb +0 -5
- data/examples/mechanika.rb +0 -409
- data/examples/parse.rb +0 -15
- data/lib/array.rb +0 -24
- data/lib/method.rb +0 -4
- data/lib/object.rb +0 -5
- data/lib/proc.rb +0 -4
- data/lib/rubylog/builtins.rb +0 -193
- data/lib/rubylog/callable.rb +0 -20
- data/lib/rubylog/composite_term.rb +0 -38
- data/lib/rubylog/dsl/constants.rb +0 -15
- data/lib/rubylog/dsl/first_order_functors.rb +0 -9
- data/lib/rubylog/dsl/global_functors.rb +0 -3
- data/lib/rubylog/dsl/second_order_functors.rb +0 -8
- data/lib/rubylog/internal_helpers.rb +0 -16
- data/lib/rubylog/predicate.rb +0 -34
- data/lib/rubylog/proc_method_additions.rb +0 -69
- data/lib/rubylog/term.rb +0 -20
- data/lib/rubylog/unifiable.rb +0 -19
- data/lib/symbol.rb +0 -35
- data/script/inriasuite2spec +0 -0
- data/script/inriasuite2spec.pl +0 -22
- data/spec/rubylog/clause_spec.rb +0 -81
- data/spec/rubylog/variable_spec.rb +0 -25
- data/spec/rubylog_spec.rb +0 -914
@@ -0,0 +1,84 @@
|
|
1
|
+
theory "Uni" do
|
2
|
+
subject Symbol
|
3
|
+
functor :likes
|
4
|
+
end
|
5
|
+
|
6
|
+
describe "unification" do
|
7
|
+
it "works for variables" do
|
8
|
+
result = false
|
9
|
+
A.rubylog_unify(12) { result = true }
|
10
|
+
result.should == true
|
11
|
+
end
|
12
|
+
it "works for used classes" do
|
13
|
+
result = false
|
14
|
+
:john.rubylog_unify(A) { result = true }
|
15
|
+
result.should == true
|
16
|
+
end
|
17
|
+
it "works for constants" do
|
18
|
+
result = false
|
19
|
+
:john.rubylog_unify(:john) { result = true }
|
20
|
+
result.should == true
|
21
|
+
end
|
22
|
+
it "fails for different constants" do
|
23
|
+
result = false
|
24
|
+
:john.rubylog_unify(:mary) { result = true }
|
25
|
+
result.should == false
|
26
|
+
end
|
27
|
+
it "works on clauses" do
|
28
|
+
result = false
|
29
|
+
(:john.likes :beer).rubylog_unify(A.likes B) { result = true }
|
30
|
+
result.should == true
|
31
|
+
end
|
32
|
+
it "works on clauses with equal values" do
|
33
|
+
result = false
|
34
|
+
(:john.likes :beer).rubylog_unify(:john.likes :beer) { result = true }
|
35
|
+
result.should == true
|
36
|
+
end
|
37
|
+
it "works on clauses with different values" do
|
38
|
+
result = false
|
39
|
+
(:john.likes :beer).rubylog_unify(:john.likes :milk) { result = true }
|
40
|
+
result.should == false
|
41
|
+
end
|
42
|
+
it "works on clauses with variables and equal values" do
|
43
|
+
result = false
|
44
|
+
(:john.likes :beer).rubylog_unify(X.likes :beer) { result = true }
|
45
|
+
result.should == true
|
46
|
+
end
|
47
|
+
it "works on clauses with variables and equal values #2" do
|
48
|
+
result = false
|
49
|
+
(:john.likes :beer).rubylog_unify(:john.likes DRINK) { result = true }
|
50
|
+
result.should == true
|
51
|
+
end
|
52
|
+
it "works on clauses with variables and different values" do
|
53
|
+
result = false
|
54
|
+
(:john.likes :beer).rubylog_unify(X.likes :milk) { result = true }
|
55
|
+
result.should == false
|
56
|
+
end
|
57
|
+
it "works on clauses with variables and different values #2" do
|
58
|
+
result = false
|
59
|
+
(:john.likes :beer).rubylog_unify(:jane.likes D) { result = true }
|
60
|
+
result.should == false
|
61
|
+
end
|
62
|
+
|
63
|
+
it "works on clauses with repeated variables #1" do
|
64
|
+
result = false
|
65
|
+
(A.likes A).rubylog_compile_variables.rubylog_unify(:john.likes :jane) { result = true }
|
66
|
+
result.should == false
|
67
|
+
(A.likes A).rubylog_compile_variables.rubylog_unify(:john.likes :john) { result = true }
|
68
|
+
result.should == true
|
69
|
+
end
|
70
|
+
it "works on clauses with repeated variables #1" do
|
71
|
+
result = false
|
72
|
+
(:john.likes :jane).rubylog_unify(A.likes(A).rubylog_compile_variables) { result = true }
|
73
|
+
result.should == false
|
74
|
+
(:john.likes :john).rubylog_unify(A.likes(A).rubylog_compile_variables) { result = true }
|
75
|
+
result.should == true
|
76
|
+
end
|
77
|
+
|
78
|
+
it "works for second-order variables" do
|
79
|
+
result = false
|
80
|
+
(:john.likes :beer).rubylog_unify(A) { result = true }
|
81
|
+
result.should == true
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubylog'
|
2
|
+
|
3
|
+
theory "Vars" do
|
4
|
+
end
|
5
|
+
describe "variables" do
|
6
|
+
it "are undefined constants" do
|
7
|
+
[A, SomethingLong].each{|x|x.should be_kind_of Rubylog::Variable}
|
8
|
+
end
|
9
|
+
|
10
|
+
it "support ==" do
|
11
|
+
A.should == A
|
12
|
+
end
|
13
|
+
|
14
|
+
it "support eql?" do
|
15
|
+
A.should be_eql A
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns different instances" do
|
19
|
+
A.should_not be_equal A
|
20
|
+
end
|
21
|
+
|
22
|
+
specify "that start with ANY... are dont care" do
|
23
|
+
[ANY, ANYTHING, ANYTIME].each{|x|x.should be_kind_of Rubylog::Variable; x.should be_dont_care}
|
24
|
+
[NOBODY, EVERYBODY, SOMEBODY].each{|x|x.should be_kind_of Rubylog::Variable; x.should_not be_dont_care}
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,230 +1,210 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubylog
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
segments_generated: true
|
11
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
12
6
|
platform: ruby
|
13
|
-
authors:
|
14
|
-
-
|
7
|
+
authors:
|
8
|
+
- Bernát Kalló
|
15
9
|
autorequire:
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
23
|
-
prerelease: false
|
12
|
+
date: 2013-02-27 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
24
15
|
name: rspec
|
25
|
-
|
16
|
+
requirement: &87769710 !ruby/object:Gem::Requirement
|
26
17
|
none: false
|
27
|
-
requirements:
|
18
|
+
requirements:
|
28
19
|
- - ~>
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
hash: 47
|
31
|
-
segments:
|
32
|
-
- 2
|
33
|
-
- 8
|
34
|
-
- 0
|
35
|
-
segments_generated: true
|
20
|
+
- !ruby/object:Gem::Version
|
36
21
|
version: 2.8.0
|
37
|
-
requirement: *id001
|
38
22
|
type: :development
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
23
|
prerelease: false
|
24
|
+
version_requirements: *87769710
|
25
|
+
- !ruby/object:Gem::Dependency
|
41
26
|
name: yard
|
42
|
-
|
27
|
+
requirement: &87769290 !ruby/object:Gem::Requirement
|
43
28
|
none: false
|
44
|
-
requirements:
|
29
|
+
requirements:
|
45
30
|
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
|
48
|
-
segments:
|
49
|
-
- 0
|
50
|
-
- 7
|
51
|
-
segments_generated: true
|
52
|
-
version: "0.7"
|
53
|
-
requirement: *id002
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.7'
|
54
33
|
type: :development
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
34
|
prerelease: false
|
35
|
+
version_requirements: *87769290
|
36
|
+
- !ruby/object:Gem::Dependency
|
57
37
|
name: rdoc
|
58
|
-
|
38
|
+
requirement: &87768850 !ruby/object:Gem::Requirement
|
59
39
|
none: false
|
60
|
-
requirements:
|
40
|
+
requirements:
|
61
41
|
- - ~>
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
|
64
|
-
segments:
|
65
|
-
- 3
|
66
|
-
- 12
|
67
|
-
segments_generated: true
|
68
|
-
version: "3.12"
|
69
|
-
requirement: *id003
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.12'
|
70
44
|
type: :development
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
45
|
prerelease: false
|
46
|
+
version_requirements: *87768850
|
47
|
+
- !ruby/object:Gem::Dependency
|
73
48
|
name: cucumber
|
74
|
-
|
49
|
+
requirement: &87722730 !ruby/object:Gem::Requirement
|
75
50
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
segments_generated: true
|
83
|
-
version: "0"
|
84
|
-
requirement: *id004
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
85
55
|
type: :development
|
86
|
-
- !ruby/object:Gem::Dependency
|
87
56
|
prerelease: false
|
57
|
+
version_requirements: *87722730
|
58
|
+
- !ruby/object:Gem::Dependency
|
88
59
|
name: bundler
|
89
|
-
|
60
|
+
requirement: &87722330 !ruby/object:Gem::Requirement
|
90
61
|
none: false
|
91
|
-
requirements:
|
62
|
+
requirements:
|
92
63
|
- - ~>
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
hash: 23
|
95
|
-
segments:
|
96
|
-
- 1
|
97
|
-
- 0
|
98
|
-
- 0
|
99
|
-
segments_generated: true
|
64
|
+
- !ruby/object:Gem::Version
|
100
65
|
version: 1.0.0
|
101
|
-
requirement: *id005
|
102
66
|
type: :development
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
67
|
prerelease: false
|
68
|
+
version_requirements: *87722330
|
69
|
+
- !ruby/object:Gem::Dependency
|
105
70
|
name: jeweler
|
106
|
-
|
71
|
+
requirement: &87721950 !ruby/object:Gem::Requirement
|
107
72
|
none: false
|
108
|
-
requirements:
|
73
|
+
requirements:
|
109
74
|
- - ~>
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
hash: 49
|
112
|
-
segments:
|
113
|
-
- 1
|
114
|
-
- 8
|
115
|
-
- 3
|
116
|
-
segments_generated: true
|
75
|
+
- !ruby/object:Gem::Version
|
117
76
|
version: 1.8.3
|
118
|
-
requirement: *id006
|
119
77
|
type: :development
|
120
|
-
- !ruby/object:Gem::Dependency
|
121
78
|
prerelease: false
|
79
|
+
version_requirements: *87721950
|
80
|
+
- !ruby/object:Gem::Dependency
|
122
81
|
name: simplecov
|
123
|
-
|
82
|
+
requirement: &87721520 !ruby/object:Gem::Requirement
|
124
83
|
none: false
|
125
|
-
requirements:
|
126
|
-
- -
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
segments_generated: true
|
132
|
-
version: "0"
|
133
|
-
requirement: *id007
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
134
88
|
type: :development
|
135
|
-
- !ruby/object:Gem::Dependency
|
136
89
|
prerelease: false
|
90
|
+
version_requirements: *87721520
|
91
|
+
- !ruby/object:Gem::Dependency
|
137
92
|
name: reek
|
138
|
-
|
93
|
+
requirement: &87721210 !ruby/object:Gem::Requirement
|
139
94
|
none: false
|
140
|
-
requirements:
|
95
|
+
requirements:
|
141
96
|
- - ~>
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
hash: 15
|
144
|
-
segments:
|
145
|
-
- 1
|
146
|
-
- 2
|
147
|
-
- 8
|
148
|
-
segments_generated: true
|
97
|
+
- !ruby/object:Gem::Version
|
149
98
|
version: 1.2.8
|
150
|
-
requirement: *id008
|
151
99
|
type: :development
|
152
|
-
- !ruby/object:Gem::Dependency
|
153
100
|
prerelease: false
|
101
|
+
version_requirements: *87721210
|
102
|
+
- !ruby/object:Gem::Dependency
|
154
103
|
name: roodi
|
155
|
-
|
104
|
+
requirement: &87720840 !ruby/object:Gem::Requirement
|
156
105
|
none: false
|
157
|
-
requirements:
|
106
|
+
requirements:
|
158
107
|
- - ~>
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
hash: 11
|
161
|
-
segments:
|
162
|
-
- 2
|
163
|
-
- 1
|
164
|
-
- 0
|
165
|
-
segments_generated: true
|
108
|
+
- !ruby/object:Gem::Version
|
166
109
|
version: 2.1.0
|
167
|
-
requirement: *id009
|
168
110
|
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *87720840
|
169
113
|
description: Rubylog is an embedded Prolog language and interpreter for Ruby.
|
170
114
|
email: kallo.bernat@gmail.com
|
171
|
-
executables:
|
172
|
-
|
115
|
+
executables:
|
116
|
+
- rubylog
|
173
117
|
extensions: []
|
174
|
-
|
175
|
-
extra_rdoc_files:
|
118
|
+
extra_rdoc_files:
|
176
119
|
- LICENSE.txt
|
120
|
+
- README.hu.rb
|
177
121
|
- README.rdoc
|
178
|
-
files:
|
122
|
+
files:
|
179
123
|
- .document
|
180
124
|
- .rspec
|
181
125
|
- Gemfile
|
182
126
|
- Gemfile.lock
|
183
127
|
- LICENSE.txt
|
128
|
+
- README.hu.rb
|
184
129
|
- README.rdoc
|
185
130
|
- Rakefile
|
186
131
|
- VERSION
|
187
|
-
-
|
188
|
-
- examples/
|
189
|
-
- examples/
|
132
|
+
- bin/rubylog
|
133
|
+
- examples/dcg.rb
|
134
|
+
- examples/dcg2.rb
|
135
|
+
- examples/enumerators.rb
|
190
136
|
- examples/factorial.rb
|
191
|
-
- examples/
|
137
|
+
- examples/hanoi.rb
|
192
138
|
- examples/hello.rb
|
193
|
-
- examples/
|
194
|
-
- examples/
|
195
|
-
- examples/lists.rb
|
196
|
-
- examples/mechanika.rb
|
197
|
-
- examples/parse.rb
|
139
|
+
- examples/parsing.rb
|
140
|
+
- examples/primitives.rb
|
198
141
|
- examples/theory.rb
|
199
|
-
- lib/array.rb
|
200
|
-
- lib/class.rb
|
201
|
-
- lib/method.rb
|
202
|
-
- lib/object.rb
|
203
|
-
- lib/proc.rb
|
204
142
|
- lib/rubylog.rb
|
205
|
-
- lib/rubylog/builtins.rb
|
206
|
-
- lib/rubylog/
|
207
|
-
- lib/rubylog/
|
208
|
-
- lib/rubylog/
|
143
|
+
- lib/rubylog/builtins/default.rb
|
144
|
+
- lib/rubylog/builtins/file_system.rb
|
145
|
+
- lib/rubylog/builtins/logic.rb
|
146
|
+
- lib/rubylog/builtins/reflection.rb
|
147
|
+
- lib/rubylog/builtins/term.rb
|
209
148
|
- lib/rubylog/dsl.rb
|
210
|
-
- lib/rubylog/dsl/
|
211
|
-
- lib/rubylog/dsl/
|
212
|
-
- lib/rubylog/dsl/
|
213
|
-
- lib/rubylog/dsl/
|
149
|
+
- lib/rubylog/dsl/array_splat.rb
|
150
|
+
- lib/rubylog/dsl/primitives.rb
|
151
|
+
- lib/rubylog/dsl/thats.rb
|
152
|
+
- lib/rubylog/dsl/variables.rb
|
214
153
|
- lib/rubylog/errors.rb
|
215
|
-
- lib/rubylog/
|
216
|
-
- lib/rubylog/
|
217
|
-
- lib/rubylog/
|
218
|
-
- lib/rubylog/
|
154
|
+
- lib/rubylog/interfaces/assertable.rb
|
155
|
+
- lib/rubylog/interfaces/callable.rb
|
156
|
+
- lib/rubylog/interfaces/composite_term.rb
|
157
|
+
- lib/rubylog/interfaces/predicate.rb
|
158
|
+
- lib/rubylog/interfaces/procedure.rb
|
159
|
+
- lib/rubylog/interfaces/term.rb
|
160
|
+
- lib/rubylog/mixins/array.rb
|
161
|
+
- lib/rubylog/mixins/class.rb
|
162
|
+
- lib/rubylog/mixins/hash.rb
|
163
|
+
- lib/rubylog/mixins/kernel.rb
|
164
|
+
- lib/rubylog/mixins/method.rb
|
165
|
+
- lib/rubylog/mixins/object.rb
|
166
|
+
- lib/rubylog/mixins/proc.rb
|
167
|
+
- lib/rubylog/mixins/string.rb
|
168
|
+
- lib/rubylog/mixins/symbol.rb
|
169
|
+
- lib/rubylog/simple_procedure.rb
|
170
|
+
- lib/rubylog/structure.rb
|
219
171
|
- lib/rubylog/theory.rb
|
220
|
-
- lib/rubylog/unifiable.rb
|
221
172
|
- lib/rubylog/variable.rb
|
222
|
-
-
|
173
|
+
- logic/builtins/file_system_logic.rb
|
174
|
+
- logic/builtins/reflection_logic.rb
|
175
|
+
- logic/dereference_logic.rb
|
176
|
+
- logic/directory_structure_logic.rb
|
177
|
+
- logic/dsl_logic.rb
|
178
|
+
- logic/errors_logic.rb
|
179
|
+
- logic/guard_logic.rb
|
180
|
+
- logic/list_logic.rb
|
181
|
+
- logic/map_logic.rb
|
182
|
+
- logic/multitheory.rb
|
183
|
+
- logic/recursion_logic.rb
|
184
|
+
- logic/string_logic.rb
|
185
|
+
- logic/thats_logic.rb
|
186
|
+
- logic/variable_logic.rb
|
223
187
|
- rubylog.gemspec
|
224
|
-
- script/inriasuite2spec
|
225
|
-
- script/inriasuite2spec.pl
|
226
188
|
- spec/bartak_guide_spec.rb
|
227
|
-
- spec/
|
189
|
+
- spec/builtins/all_spec.rb
|
190
|
+
- spec/builtins/and_spec.rb
|
191
|
+
- spec/builtins/array_spec.rb
|
192
|
+
- spec/builtins/branch_or_spec.rb
|
193
|
+
- spec/builtins/cut_spec.rb
|
194
|
+
- spec/builtins/fail_spec.rb
|
195
|
+
- spec/builtins/false_spec.rb
|
196
|
+
- spec/builtins/in_spec.rb
|
197
|
+
- spec/builtins/is_false_spec.rb
|
198
|
+
- spec/builtins/is_spec.rb
|
199
|
+
- spec/builtins/matches_spec.rb
|
200
|
+
- spec/builtins/or_spec.rb
|
201
|
+
- spec/builtins/splits_to.rb
|
202
|
+
- spec/builtins/then_spec.rb
|
203
|
+
- spec/builtins/true_spec.rb
|
204
|
+
- spec/clause_spec.rb
|
205
|
+
- spec/compilation_spec.rb
|
206
|
+
- spec/custom_classes_spec.rb
|
207
|
+
- spec/dereference.rb
|
228
208
|
- spec/inriasuite/README
|
229
209
|
- spec/inriasuite/abolish
|
230
210
|
- spec/inriasuite/and
|
@@ -292,48 +272,41 @@ files:
|
|
292
272
|
- spec/inriasuite/term_lt=
|
293
273
|
- spec/inriasuite/true
|
294
274
|
- spec/inriasuite/unify
|
275
|
+
- spec/inriasuite_spec.rb
|
276
|
+
- spec/queries_spec.rb
|
295
277
|
- spec/recursion_spec.rb
|
296
|
-
- spec/
|
297
|
-
- spec/
|
298
|
-
- spec/rubylog/variable_spec.rb
|
299
|
-
- spec/rubylog_spec.rb
|
278
|
+
- spec/ruby_code_spec.rb
|
279
|
+
- spec/rules_spec.rb
|
300
280
|
- spec/spec_helper.rb
|
301
281
|
- spec/theory_spec.rb
|
302
|
-
|
282
|
+
- spec/unification_spec.rb
|
283
|
+
- spec/variable_spec.rb
|
303
284
|
homepage: https://github.com/cie/rubylog
|
304
|
-
licenses:
|
285
|
+
licenses:
|
305
286
|
- MIT
|
306
287
|
post_install_message:
|
307
288
|
rdoc_options: []
|
308
|
-
|
309
|
-
require_paths:
|
289
|
+
require_paths:
|
310
290
|
- lib
|
311
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
291
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
312
292
|
none: false
|
313
|
-
requirements:
|
314
|
-
- -
|
315
|
-
- !ruby/object:Gem::Version
|
316
|
-
|
317
|
-
segments:
|
293
|
+
requirements:
|
294
|
+
- - ! '>='
|
295
|
+
- !ruby/object:Gem::Version
|
296
|
+
version: '0'
|
297
|
+
segments:
|
318
298
|
- 0
|
319
|
-
|
320
|
-
|
321
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
|
+
hash: -824234275
|
300
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
322
301
|
none: false
|
323
|
-
requirements:
|
324
|
-
- -
|
325
|
-
- !ruby/object:Gem::Version
|
326
|
-
|
327
|
-
segments:
|
328
|
-
- 0
|
329
|
-
segments_generated: true
|
330
|
-
version: "0"
|
302
|
+
requirements:
|
303
|
+
- - ! '>='
|
304
|
+
- !ruby/object:Gem::Version
|
305
|
+
version: '0'
|
331
306
|
requirements: []
|
332
|
-
|
333
307
|
rubyforge_project:
|
334
|
-
rubygems_version: 1.
|
308
|
+
rubygems_version: 1.8.15
|
335
309
|
signing_key:
|
336
310
|
specification_version: 3
|
337
311
|
summary: An embedded Prolog interpreter
|
338
312
|
test_files: []
|
339
|
-
|
data/examples/4queens.rb
DELETED
data/examples/calculation.rb
DELETED
data/examples/concepts.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
|
2
|
-
X.clause.if X.fact
|
3
|
-
X.clause.if X.rule
|
4
|
-
X.clause.if X.query
|
5
|
-
|
6
|
-
X.comment.if X.starts_with('%')
|
7
|
-
|
8
|
-
X.predicate.if X.procedure
|
9
|
-
|
10
|
-
X.procedure.if X.has_many(clause)
|
11
|
-
|
12
|
-
|
13
|
-
X.operator.if X.comparison_operator
|
14
|
-
X.operator.if X.arithmetic_operator
|
15
|
-
|
16
|
-
X.comparison_operator.if X.arithmetic_comparison_operator.or X.unification_style_operator
|
17
|
-
|
18
|
-
X.unification_style_operator.if X === :===
|
19
|
-
X.unification_style_operator.if X === :==
|
20
|
-
|
21
|
-
X.arithmetic_comparison_operator.if X === :<
|
22
|
-
X.arithmetic_comparison_operator.if X === :<=
|
23
|
-
X.arithmetic_comparison_operator.if X === :>
|
24
|
-
X.arithmetic_comparison_operator.if X === :>=
|
25
|
-
|
26
|
-
X.arithmetic_operator.if X === :+
|
27
|
-
X.arithmetic_operator.if X === :-
|
28
|
-
X.arithmetic_operator.if X === :-@
|
29
|
-
X.arithmetic_operator.if X === :*
|
30
|
-
X.arithmetic_operator.if X === :/
|
31
|
-
X.arithmetic_operator.if X === :%
|
32
|
-
X.arithmetic_operator.if X === :**
|
33
|
-
X.arithmetic_operator.if X === :<=>
|
34
|
-
X.arithmetic_operator.if X === :&
|
35
|
-
X.arithmetic_operator.if X === :|
|
36
|
-
X.arithmetic_operator.if X === :^
|
37
|
-
X.arithmetic_operator.if X === :~
|
38
|
-
X.arithmetic_operator.if X === :<<
|
39
|
-
X.arithmetic_operator.if X === :>>
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
X.builtin.if X === :arg
|
45
|
-
X.builtin.if X === :forget
|
46
|
-
|
data/examples/fp.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
|
3
|
-
This is a port of some little Haskell programs
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
zipPair :: ([a],[b]) -> [(a,b)]
|
10
|
-
-- zipPair = uncurry zip
|
11
|
-
zipPair (_,[]) = []
|
12
|
-
zipPair ([],_) = []
|
13
|
-
zipPair ((a:as), (b:bs)) = (a,b) : zipPair (as,bs)
|
14
|
-
|
15
|
-
=end
|
16
|
-
|
17
|
-
class << Rubylog::Theory.new!
|
18
|
-
|
19
|
-
rubylog_functor
|
20
|
-
|
21
|
-
# multiply 0 _ = []
|
22
|
-
# multiply n k = k : multiply (n-1) k
|
23
|
-
#
|
24
|
-
(N.times X, XS).if XS.is{|n,x| n*[x] }
|
25
|
-
|
26
|
-
|
27
|
-
# dividers n = filter (`divides` n) [1..n `div` 2]
|
28
|
-
# where a `divides` b = b `mod` a == 0
|
29
|
-
# isPerfectNumber n = n == (sum $ dividers n)
|
30
|
-
|
31
|
-
(A.divides B).if {|a,b| b % a == 0}
|
32
|
-
(A.divider_of B).if A.in{|a,b| (1..b%2)}.and A.divides B
|
33
|
-
(N.perfect_number).if DS.is{|n| (D.divider_of n).to_a }.and DS.sum N
|
34
|
-
(L.sum S).if S.is{|l| l.inject(0){|a,b|a+b}}
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# mirrorList [] = []
|
39
|
-
# mirrorList (a:as) = mirrorList as ++ [a]
|
40
|
-
(L.mirrored M).if M.is{|l|l.reverse}
|
41
|
-
|
42
|
-
|
43
|
-
# intermix [] _ = []
|
44
|
-
# intermix [a] _ = [a]
|
45
|
-
# intermix (a:as) b = a:b:intermix as b
|
46
|
-
(L.intermix E, M).if M.is{|l,e|l[1..-1].inject [l[0]] {|a,b| a << e << b }}
|
47
|
-
# possible:
|
48
|
-
#([].intermix ANY, [])
|
49
|
-
#([A].intermix ANY, [A])
|
50
|
-
#((:|[A,AS]).intermix B, :|[A,B,L]).if (AS.intermix B, L)
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
|