rubylog 1.0.0 → 2.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -12
- data/Gemfile.lock +22 -48
- data/README.rdoc +38 -38
- data/README.rdoc.orig +284 -0
- data/RELEASE_NOTES.rdoc +51 -0
- data/Rakefile +14 -18
- data/TODO.txt +0 -0
- data/VERSION +1 -1
- data/examples/a_plus_b.rb +6 -0
- data/examples/checkmate.rb +88 -0
- data/examples/combination.rb +17 -0
- data/examples/dcg.rb +3 -2
- data/examples/dcg2.rb +2 -2
- data/{logic → examples}/directory_structure_logic.rb +3 -5
- data/examples/dirlist.rb +4 -0
- data/examples/divisors.rb +6 -0
- data/examples/enumerators.rb +3 -3
- data/examples/factorial.rb +2 -3
- data/examples/file_search.rb +14 -0
- data/examples/hanoi.rb +4 -5
- data/examples/hello.rb +6 -4
- data/examples/mice.rb +92 -0
- data/examples/mice2.rb +19 -0
- data/examples/n_queens.rb +32 -0
- data/examples/object_oriented.rb +14 -0
- data/examples/palindrome_detection.rb +18 -0
- data/examples/parsing.rb +6 -4
- data/examples/permutation.rb +12 -0
- data/examples/prefix.rb +13 -0
- data/examples/primality_by_division.rb +22 -0
- data/examples/primitives.rb +10 -8
- data/examples/sieve_of_eratosthenes.rb +14 -0
- data/examples/string_interpolation.rb +4 -0
- data/examples/sudoku.rb +52 -0
- data/examples/tracing.rb +19 -0
- data/lib/rspec/rubylog.rb +29 -0
- data/lib/rubylog/assertable.rb +24 -0
- data/lib/rubylog/builtins/arithmetics.rb +63 -0
- data/lib/rubylog/builtins/assumption.rb +71 -0
- data/lib/rubylog/builtins/ensure.rb +13 -0
- data/lib/rubylog/builtins/file_system.rb +30 -8
- data/lib/rubylog/builtins/logic.rb +69 -38
- data/lib/rubylog/builtins/reflection.rb +35 -50
- data/lib/rubylog/builtins/term.rb +15 -17
- data/lib/rubylog/builtins.rb +11 -0
- data/lib/rubylog/clause.rb +19 -0
- data/lib/rubylog/{interfaces/composite_term.rb → compound_term.rb} +3 -3
- data/lib/rubylog/context.rb +24 -0
- data/lib/rubylog/context_creation.rb +71 -0
- data/lib/rubylog/context_modules/checks.rb +35 -0
- data/lib/rubylog/context_modules/demonstration.rb +16 -0
- data/lib/rubylog/context_modules/predicates.rb +86 -0
- data/lib/rubylog/context_modules/primitives.rb +18 -0
- data/lib/rubylog/context_modules/thats.rb +13 -0
- data/lib/rubylog/default_context.rb +9 -0
- data/lib/rubylog/dsl/array_splat.rb +11 -3
- data/lib/rubylog/dsl/primitives.rb +24 -12
- data/lib/rubylog/dsl/thats.rb +6 -0
- data/lib/rubylog/dsl/variables.rb +56 -21
- data/lib/rubylog/errors.rb +26 -15
- data/lib/rubylog/mixins/array.rb +95 -62
- data/lib/rubylog/mixins/kernel.rb +3 -2
- data/lib/rubylog/mixins/method.rb +0 -1
- data/lib/rubylog/mixins/object.rb +2 -1
- data/lib/rubylog/mixins/proc.rb +9 -12
- data/lib/rubylog/mixins/string.rb +15 -23
- data/lib/rubylog/mixins/symbol.rb +7 -24
- data/lib/rubylog/nullary_predicates.rb +3 -0
- data/lib/rubylog/predicate.rb +53 -0
- data/lib/rubylog/primitive.rb +15 -0
- data/lib/rubylog/procedure.rb +42 -0
- data/lib/rubylog/rule.rb +24 -0
- data/lib/rubylog/structure.rb +19 -38
- data/lib/rubylog/{interfaces/term.rb → term.rb} +2 -7
- data/lib/rubylog/tracing.rb +75 -0
- data/lib/rubylog/variable.rb +31 -12
- data/lib/rubylog.rb +36 -32
- data/rubylog.gemspec +92 -84
- data/spec/inriasuite_spec.rb +906 -9
- data/spec/integration/custom_classes_spec.rb +61 -0
- data/spec/integration/dsl_spec.rb +38 -0
- data/spec/integration/recursion_spec.rb +14 -0
- data/spec/integration/theory_as_module_spec.rb +20 -0
- data/spec/integration/theory_as_module_with_include_spec.rb +14 -0
- data/spec/rspec/rubylog_spec.rb +75 -0
- data/spec/rubylog/assertable_spec.rb +111 -0
- data/spec/rubylog/builtins/arithmetics_spec.rb +94 -0
- data/spec/rubylog/builtins/assumption_spec.rb +70 -0
- data/spec/rubylog/builtins/ensure_spec.rb +8 -0
- data/spec/rubylog/builtins/file_system_spec.rb +40 -0
- data/spec/rubylog/builtins/logic_spec.rb +340 -0
- data/spec/rubylog/builtins/reflection_spec.rb +43 -0
- data/spec/rubylog/builtins/term_spec.rb +85 -0
- data/spec/rubylog/context_modules/demonstration_spec.rb +132 -0
- data/spec/rubylog/context_modules/predicates_spec.rb +57 -0
- data/spec/rubylog/context_modules/thats_spec.rb +94 -0
- data/spec/rubylog/dsl/array_splat_spec.rb +15 -0
- data/spec/rubylog/dsl/primitives_spec.rb +43 -0
- data/spec/rubylog/errors_spec.rb +18 -0
- data/spec/{unification_spec.rb → rubylog/interfaces/term_spec.rb} +8 -9
- data/spec/rubylog/mixins/array_spec.rb +80 -0
- data/spec/rubylog/mixins/composite_term_spec.rb +66 -0
- data/spec/rubylog/mixins/proc_spec.rb +59 -0
- data/spec/rubylog/mixins/string_spec.rb +48 -0
- data/spec/rubylog/mixins/symbol_spec.rb +9 -0
- data/spec/{clause_spec.rb → rubylog/structure_spec.rb} +16 -15
- data/spec/rubylog/term_spec.rb +7 -0
- data/spec/rubylog/tracing_spec.input +27 -0
- data/spec/rubylog/tracing_spec.rb +44 -0
- data/spec/rubylog/variable_spec.rb +279 -0
- data/spec/spec_helper.rb +1 -0
- data/vimrc +11 -0
- metadata +103 -123
- data/README.hu.rb +0 -58
- data/bin/rubylog +0 -18
- data/examples/theory.rb +0 -32
- data/lib/rubylog/builtins/default.rb +0 -10
- data/lib/rubylog/dsl.rb +0 -70
- data/lib/rubylog/interfaces/assertable.rb +0 -16
- data/lib/rubylog/interfaces/callable.rb +0 -18
- data/lib/rubylog/interfaces/predicate.rb +0 -8
- data/lib/rubylog/interfaces/procedure.rb +0 -60
- data/lib/rubylog/mixins/class.rb +0 -11
- data/lib/rubylog/simple_procedure.rb +0 -8
- data/lib/rubylog/theory.rb +0 -422
- data/logic/builtins/file_system_logic.rb +0 -23
- data/logic/builtins/reflection_logic.rb +0 -40
- data/logic/dereference_logic.rb +0 -23
- data/logic/dsl_logic.rb +0 -29
- data/logic/errors_logic.rb +0 -9
- data/logic/guard_logic.rb +0 -115
- data/logic/list_logic.rb +0 -55
- data/logic/map_logic.rb +0 -15
- data/logic/multitheory.rb +0 -23
- data/logic/recursion_logic.rb +0 -12
- data/logic/string_logic.rb +0 -41
- data/logic/thats_logic.rb +0 -51
- data/logic/variable_logic.rb +0 -24
- data/spec/bartak_guide_spec.rb +0 -86
- data/spec/builtins/all_spec.rb +0 -99
- data/spec/builtins/and_spec.rb +0 -22
- data/spec/builtins/array_spec.rb +0 -16
- data/spec/builtins/branch_or_spec.rb +0 -27
- data/spec/builtins/cut_spec.rb +0 -44
- data/spec/builtins/fail_spec.rb +0 -5
- data/spec/builtins/false_spec.rb +0 -5
- data/spec/builtins/in_spec.rb +0 -38
- data/spec/builtins/is_false_spec.rb +0 -12
- data/spec/builtins/is_spec.rb +0 -26
- data/spec/builtins/matches_spec.rb +0 -23
- data/spec/builtins/or_spec.rb +0 -22
- data/spec/builtins/splits_to.rb +0 -18
- data/spec/builtins/then_spec.rb +0 -27
- data/spec/builtins/true_spec.rb +0 -5
- data/spec/compilation_spec.rb +0 -61
- data/spec/custom_classes_spec.rb +0 -43
- data/spec/dereference.rb +0 -10
- data/spec/queries_spec.rb +0 -150
- data/spec/recursion_spec.rb +0 -18
- data/spec/ruby_code_spec.rb +0 -52
- data/spec/rules_spec.rb +0 -97
- data/spec/theory_spec.rb +0 -29
- data/spec/variable_spec.rb +0 -26
@@ -0,0 +1,279 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rubylog::Variable, :rubylog=>true do
|
4
|
+
it "is created when an undefined constant name appears" do
|
5
|
+
[A, SomethingLong].each{|x|x.should be_kind_of Rubylog::Variable}
|
6
|
+
end
|
7
|
+
|
8
|
+
it "supports ==" do
|
9
|
+
A.should == A
|
10
|
+
end
|
11
|
+
|
12
|
+
it "supports eql?" do
|
13
|
+
A.should be_eql A
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns different instances" do
|
17
|
+
A.should_not be_equal A
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "dont-care variables" do
|
21
|
+
specify "start with ANY or Any or AnY" do
|
22
|
+
[ANY, Anything, AnYTIME].each{|x|x.should be_kind_of Rubylog::Variable; x.should be_dont_care}
|
23
|
+
[NOBODY, EVERYBODY, SOMEBODY].each{|x|x.should be_kind_of Rubylog::Variable; x.should_not be_dont_care}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#value" do
|
28
|
+
it "returns the value if bound" do
|
29
|
+
a = A
|
30
|
+
a.send :bind_to, 5 do
|
31
|
+
a.value.should == 5
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns nil if unbound" do
|
36
|
+
a = A
|
37
|
+
a.send :bind_to, 5 do
|
38
|
+
end
|
39
|
+
a.value.should == nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "unification" do
|
44
|
+
it "unifies with non-var" do
|
45
|
+
a=A
|
46
|
+
a.rubylog_unify(4) do
|
47
|
+
a.should be_bound
|
48
|
+
a.value.should eql 4
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "unifies with non-var (reversed)" do
|
53
|
+
a=A
|
54
|
+
4.rubylog_unify(a) do
|
55
|
+
a.should be_bound
|
56
|
+
a.value.should eql 4
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it "unifies with another unbound variable with the other gettin bound" do
|
61
|
+
a=A
|
62
|
+
b=B
|
63
|
+
a.rubylog_unify(b) do
|
64
|
+
b.should be_bound
|
65
|
+
b.value.should equal a
|
66
|
+
a.should_not be_bound
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "unifies with a bound variable" do
|
71
|
+
a=A
|
72
|
+
b=B
|
73
|
+
b.send(:bind_to, 4) do
|
74
|
+
a.rubylog_unify(b) do
|
75
|
+
a.value.should == 4
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "when bound, unifies with an unbound variable" do
|
81
|
+
a=A
|
82
|
+
b=B
|
83
|
+
a.send(:bind_to, 4) do
|
84
|
+
a.rubylog_unify(b) do
|
85
|
+
b.value.should == 4
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "dereferencing" do
|
92
|
+
predicate_for Integer, ".divides()"
|
93
|
+
|
94
|
+
check { A.is_a? Rubylog::Variable }
|
95
|
+
check { A.rubylog_deep_dereference == A }
|
96
|
+
|
97
|
+
a = A
|
98
|
+
check { a.rubylog_deep_dereference.equal? a }
|
99
|
+
|
100
|
+
check { not a.bound? }
|
101
|
+
|
102
|
+
specify do
|
103
|
+
a.rubylog_unify(4) do
|
104
|
+
check { a.bound? }
|
105
|
+
check { a.rubylog_deep_dereference == 4 }
|
106
|
+
check { [1,a].rubylog_deep_dereference == [1,4] }
|
107
|
+
check { a.divides(16).rubylog_deep_dereference == 4.divides(16) }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
b = []
|
112
|
+
check { not b.rubylog_deep_dereference.equal? b }
|
113
|
+
|
114
|
+
c = Object.new
|
115
|
+
check { c.rubylog_deep_dereference.equal? c }
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "dont-care variables are case insensitive ANY* and _*" do
|
119
|
+
check 3.is(ANY).and 3.is(ANY)
|
120
|
+
check 3.is(ANY).and 4.is(ANY)
|
121
|
+
check 3.is(ANYTHING).and 3.is(ANYTHING)
|
122
|
+
check 3.is(ANYTHING).and 4.is(ANYTHING)
|
123
|
+
check 3.is(Anything).and 3.is(Anything)
|
124
|
+
check 3.is(Anything).and 4.is(Anything)
|
125
|
+
check 3.is(Rubylog::Variable.new(:_var1)).and(3.is(Rubylog::Variable.new(:_var1)))
|
126
|
+
check 3.is(Rubylog::Variable.new(:_var1)).and(4.is(Rubylog::Variable.new(:_var1)))
|
127
|
+
check 3.is(Rubylog::Variable.new(:var1 )).and(3.is(Rubylog::Variable.new(:var1 )))
|
128
|
+
check 3.is(Rubylog::Variable.new(:var1 )).and(4.is(Rubylog::Variable.new(:var1 ))).false
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "dont-care variables support recursion" do
|
132
|
+
predicate_for Integer, ".factorial()"
|
133
|
+
0.factorial! 1
|
134
|
+
N.factorial(K).if proc{N > 0}.and N1.is {N-1} .and N1.factorial(K1).and K.is{ N*K1 }.and K.is(ANY1).and N.is(ANY2)
|
135
|
+
check 0.factorial 1
|
136
|
+
check 1.factorial 1
|
137
|
+
check 2.factorial 2
|
138
|
+
check 3.factorial 6
|
139
|
+
check 4.factorial 24
|
140
|
+
check 7.factorial 5040
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "calling" do
|
144
|
+
describe "precompiled" do
|
145
|
+
check B.is(4).and A.is(B.is(C).and C.is(4)).and A
|
146
|
+
check((B.is(4).and A.is(B.is(C).and C.is(3)).and A).false)
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "compiled run-time" do
|
150
|
+
check B.is(4).and A.is{B.is(C).and C.is(4)}.and A
|
151
|
+
check((B.is(4).and A.is{B.is(C).and C.is(3)}.and A).false)
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "guards", :rubylog=>true do
|
157
|
+
|
158
|
+
describe "class guard" do
|
159
|
+
predicate_for [Integer,Float], ".divides()"
|
160
|
+
A[Integer].divides(B[Integer]).if { B % A == 0 }
|
161
|
+
A[Float].divides!(B[Float])
|
162
|
+
check 2.divides(10)
|
163
|
+
check 2.divides(9).false
|
164
|
+
check 2.divides(1).false
|
165
|
+
check 2.divides(0)
|
166
|
+
check 2.12.divides(4.5)
|
167
|
+
check -0.31.divides(-1.5)
|
168
|
+
check 0.3.divides(3).false
|
169
|
+
check 2.0.divides(10).false
|
170
|
+
check 2.divides(10.0).false
|
171
|
+
check 2.divides(9.0).false
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "union of guards at compile" do
|
175
|
+
predicate_for Numeric, ".small"
|
176
|
+
A[0...100].small.if ANY.is A[Integer]
|
177
|
+
check 0.small
|
178
|
+
check 10.small
|
179
|
+
check -1.small.false
|
180
|
+
check 0.0.small.false
|
181
|
+
check 99.small
|
182
|
+
check 99.0.small.false
|
183
|
+
check 99.9.small.false
|
184
|
+
check 100.small.false
|
185
|
+
check 100.0.small.false
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "union of guards at compile (dont-care)" do
|
189
|
+
predicate_for Numeric, ".small"
|
190
|
+
A[0...100].small.if A.is ANY[Integer]
|
191
|
+
check 0.small
|
192
|
+
check 10.small
|
193
|
+
check -1.small.false
|
194
|
+
check 0.0.small.false
|
195
|
+
check 99.small
|
196
|
+
check 99.0.small.false
|
197
|
+
check 99.9.small.false
|
198
|
+
check 100.small.false
|
199
|
+
check 100.0.small.false
|
200
|
+
end
|
201
|
+
|
202
|
+
describe "union of guards at unification" do
|
203
|
+
predicate_for Numeric, ".small"
|
204
|
+
A[0...100].small.if A.is B[Integer]
|
205
|
+
check 0.small
|
206
|
+
check 10.small
|
207
|
+
check -1.small.false
|
208
|
+
check 0.0.small.false
|
209
|
+
check 99.small
|
210
|
+
check 99.0.small.false
|
211
|
+
check 99.9.small.false
|
212
|
+
check 100.small.false
|
213
|
+
check 100.0.small.false
|
214
|
+
end
|
215
|
+
|
216
|
+
describe "union of guards at unification (reversed)" do
|
217
|
+
predicate_for Numeric, ".small"
|
218
|
+
A[0...100].small.if B[Integer].is A
|
219
|
+
check 0.small
|
220
|
+
check 10.small
|
221
|
+
check -1.small.false
|
222
|
+
check 0.0.small.false
|
223
|
+
check 99.small
|
224
|
+
check 99.0.small.false
|
225
|
+
check 99.9.small.false
|
226
|
+
check 100.small.false
|
227
|
+
check 100.0.small.false
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
describe "proc guards" do
|
232
|
+
predicate_for Numeric, ".big"
|
233
|
+
A[proc{|a|a > 20}].big!
|
234
|
+
check -100.big.false
|
235
|
+
check 0.big.false
|
236
|
+
check 10.big.false
|
237
|
+
check 20.big.false
|
238
|
+
check 21.big
|
239
|
+
check 200.big
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "hash guards" do
|
243
|
+
predicate_for String, ".char"
|
244
|
+
S[length: 1].char!
|
245
|
+
check "a".char
|
246
|
+
check " ".char
|
247
|
+
check "".char.false
|
248
|
+
check "af".char.false
|
249
|
+
check "Hello".char.false
|
250
|
+
end
|
251
|
+
|
252
|
+
describe "list hash guards" do
|
253
|
+
predicate_for String, ".capitalized"
|
254
|
+
S[[:[],0] => /[A-Z]/].capitalized!
|
255
|
+
check "a".capitalized.false
|
256
|
+
check " ".capitalized.false
|
257
|
+
check "".capitalized.false
|
258
|
+
check "af".capitalized.false
|
259
|
+
check "A".capitalized
|
260
|
+
check "Hello".capitalized
|
261
|
+
end
|
262
|
+
|
263
|
+
|
264
|
+
describe "chained hash guards" do
|
265
|
+
predicate_for String, ".funny"
|
266
|
+
S[upcase: {[:[],1..-2] => "ELL"}].funny!
|
267
|
+
check "hello".funny
|
268
|
+
check "Bell!".funny
|
269
|
+
check "BELL!".funny
|
270
|
+
check "DELL".funny.false
|
271
|
+
check "help!".funny.false
|
272
|
+
check "hello!".funny.false
|
273
|
+
end
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
data/spec/spec_helper.rb
CHANGED
data/vimrc
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
set makeprg=rspec
|
2
|
+
map <F9> :make<CR><CR>
|
3
|
+
|
4
|
+
noremap r :e lib/rubylog/
|
5
|
+
noremap e :e lib/rubylog/
|
6
|
+
noremap s :sp lib/rubylog/
|
7
|
+
noremap v :vs lib/rubylog/
|
8
|
+
noremap g :!git
|
9
|
+
noremap d yiwq:ivim -def 0\>- lib**<CR>
|
10
|
+
noremap f yiwq:ivim -\<0\>- lib**<CR>
|
11
|
+
|
metadata
CHANGED
@@ -1,30 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubylog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0pre1
|
5
|
+
prerelease: 3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Bernát Kalló
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02
|
12
|
+
date: 2013-05-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &80714410 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - <
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3'
|
22
|
+
- - ! '>='
|
20
23
|
- !ruby/object:Gem::Version
|
21
24
|
version: 2.8.0
|
22
25
|
type: :development
|
23
26
|
prerelease: false
|
24
|
-
version_requirements: *
|
27
|
+
version_requirements: *80714410
|
25
28
|
- !ruby/object:Gem::Dependency
|
26
29
|
name: yard
|
27
|
-
requirement: &
|
30
|
+
requirement: &80713870 !ruby/object:Gem::Requirement
|
28
31
|
none: false
|
29
32
|
requirements:
|
30
33
|
- - ~>
|
@@ -32,54 +35,32 @@ dependencies:
|
|
32
35
|
version: '0.7'
|
33
36
|
type: :development
|
34
37
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rdoc
|
38
|
-
requirement: &87768850 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '3.12'
|
44
|
-
type: :development
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: *87768850
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: cucumber
|
49
|
-
requirement: &87722730 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *87722730
|
38
|
+
version_requirements: *80713870
|
58
39
|
- !ruby/object:Gem::Dependency
|
59
40
|
name: bundler
|
60
|
-
requirement: &
|
41
|
+
requirement: &80713360 !ruby/object:Gem::Requirement
|
61
42
|
none: false
|
62
43
|
requirements:
|
63
|
-
- -
|
44
|
+
- - ! '>='
|
64
45
|
- !ruby/object:Gem::Version
|
65
46
|
version: 1.0.0
|
66
47
|
type: :development
|
67
48
|
prerelease: false
|
68
|
-
version_requirements: *
|
49
|
+
version_requirements: *80713360
|
69
50
|
- !ruby/object:Gem::Dependency
|
70
51
|
name: jeweler
|
71
|
-
requirement: &
|
52
|
+
requirement: &80712960 !ruby/object:Gem::Requirement
|
72
53
|
none: false
|
73
54
|
requirements:
|
74
|
-
- -
|
55
|
+
- - ! '>='
|
75
56
|
- !ruby/object:Gem::Version
|
76
57
|
version: 1.8.3
|
77
58
|
type: :development
|
78
59
|
prerelease: false
|
79
|
-
version_requirements: *
|
60
|
+
version_requirements: *80712960
|
80
61
|
- !ruby/object:Gem::Dependency
|
81
62
|
name: simplecov
|
82
|
-
requirement: &
|
63
|
+
requirement: &80712570 !ruby/object:Gem::Requirement
|
83
64
|
none: false
|
84
65
|
requirements:
|
85
66
|
- - ! '>='
|
@@ -87,78 +68,80 @@ dependencies:
|
|
87
68
|
version: '0'
|
88
69
|
type: :development
|
89
70
|
prerelease: false
|
90
|
-
version_requirements: *
|
91
|
-
-
|
92
|
-
name: reek
|
93
|
-
requirement: &87721210 !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
|
-
requirements:
|
96
|
-
- - ~>
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: 1.2.8
|
99
|
-
type: :development
|
100
|
-
prerelease: false
|
101
|
-
version_requirements: *87721210
|
102
|
-
- !ruby/object:Gem::Dependency
|
103
|
-
name: roodi
|
104
|
-
requirement: &87720840 !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 2.1.0
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: *87720840
|
113
|
-
description: Rubylog is an embedded Prolog language and interpreter for Ruby.
|
71
|
+
version_requirements: *80712570
|
72
|
+
description: Rubylog is a Prolog-like DSL for Ruby.
|
114
73
|
email: kallo.bernat@gmail.com
|
115
|
-
executables:
|
116
|
-
- rubylog
|
74
|
+
executables: []
|
117
75
|
extensions: []
|
118
76
|
extra_rdoc_files:
|
119
77
|
- LICENSE.txt
|
120
|
-
- README.hu.rb
|
121
78
|
- README.rdoc
|
79
|
+
- README.rdoc.orig
|
122
80
|
files:
|
123
81
|
- .document
|
124
82
|
- .rspec
|
125
83
|
- Gemfile
|
126
84
|
- Gemfile.lock
|
127
85
|
- LICENSE.txt
|
128
|
-
- README.hu.rb
|
129
86
|
- README.rdoc
|
87
|
+
- RELEASE_NOTES.rdoc
|
130
88
|
- Rakefile
|
89
|
+
- TODO.txt
|
131
90
|
- VERSION
|
132
|
-
-
|
91
|
+
- examples/a_plus_b.rb
|
92
|
+
- examples/checkmate.rb
|
93
|
+
- examples/combination.rb
|
133
94
|
- examples/dcg.rb
|
134
95
|
- examples/dcg2.rb
|
96
|
+
- examples/directory_structure_logic.rb
|
97
|
+
- examples/dirlist.rb
|
98
|
+
- examples/divisors.rb
|
135
99
|
- examples/enumerators.rb
|
136
100
|
- examples/factorial.rb
|
101
|
+
- examples/file_search.rb
|
137
102
|
- examples/hanoi.rb
|
138
103
|
- examples/hello.rb
|
104
|
+
- examples/mice.rb
|
105
|
+
- examples/mice2.rb
|
106
|
+
- examples/n_queens.rb
|
107
|
+
- examples/object_oriented.rb
|
108
|
+
- examples/palindrome_detection.rb
|
139
109
|
- examples/parsing.rb
|
110
|
+
- examples/permutation.rb
|
111
|
+
- examples/prefix.rb
|
112
|
+
- examples/primality_by_division.rb
|
140
113
|
- examples/primitives.rb
|
141
|
-
- examples/
|
114
|
+
- examples/sieve_of_eratosthenes.rb
|
115
|
+
- examples/string_interpolation.rb
|
116
|
+
- examples/sudoku.rb
|
117
|
+
- examples/tracing.rb
|
118
|
+
- lib/rspec/rubylog.rb
|
142
119
|
- lib/rubylog.rb
|
143
|
-
- lib/rubylog/
|
120
|
+
- lib/rubylog/assertable.rb
|
121
|
+
- lib/rubylog/builtins.rb
|
122
|
+
- lib/rubylog/builtins/arithmetics.rb
|
123
|
+
- lib/rubylog/builtins/assumption.rb
|
124
|
+
- lib/rubylog/builtins/ensure.rb
|
144
125
|
- lib/rubylog/builtins/file_system.rb
|
145
126
|
- lib/rubylog/builtins/logic.rb
|
146
127
|
- lib/rubylog/builtins/reflection.rb
|
147
128
|
- lib/rubylog/builtins/term.rb
|
148
|
-
- lib/rubylog/
|
129
|
+
- lib/rubylog/clause.rb
|
130
|
+
- lib/rubylog/compound_term.rb
|
131
|
+
- lib/rubylog/context.rb
|
132
|
+
- lib/rubylog/context_creation.rb
|
133
|
+
- lib/rubylog/context_modules/checks.rb
|
134
|
+
- lib/rubylog/context_modules/demonstration.rb
|
135
|
+
- lib/rubylog/context_modules/predicates.rb
|
136
|
+
- lib/rubylog/context_modules/primitives.rb
|
137
|
+
- lib/rubylog/context_modules/thats.rb
|
138
|
+
- lib/rubylog/default_context.rb
|
149
139
|
- lib/rubylog/dsl/array_splat.rb
|
150
140
|
- lib/rubylog/dsl/primitives.rb
|
151
141
|
- lib/rubylog/dsl/thats.rb
|
152
142
|
- lib/rubylog/dsl/variables.rb
|
153
143
|
- lib/rubylog/errors.rb
|
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
144
|
- lib/rubylog/mixins/array.rb
|
161
|
-
- lib/rubylog/mixins/class.rb
|
162
145
|
- lib/rubylog/mixins/hash.rb
|
163
146
|
- lib/rubylog/mixins/kernel.rb
|
164
147
|
- lib/rubylog/mixins/method.rb
|
@@ -166,45 +149,16 @@ files:
|
|
166
149
|
- lib/rubylog/mixins/proc.rb
|
167
150
|
- lib/rubylog/mixins/string.rb
|
168
151
|
- lib/rubylog/mixins/symbol.rb
|
169
|
-
- lib/rubylog/
|
152
|
+
- lib/rubylog/nullary_predicates.rb
|
153
|
+
- lib/rubylog/predicate.rb
|
154
|
+
- lib/rubylog/primitive.rb
|
155
|
+
- lib/rubylog/procedure.rb
|
156
|
+
- lib/rubylog/rule.rb
|
170
157
|
- lib/rubylog/structure.rb
|
171
|
-
- lib/rubylog/
|
158
|
+
- lib/rubylog/term.rb
|
159
|
+
- lib/rubylog/tracing.rb
|
172
160
|
- lib/rubylog/variable.rb
|
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
|
187
161
|
- rubylog.gemspec
|
188
|
-
- spec/bartak_guide_spec.rb
|
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
|
208
162
|
- spec/inriasuite/README
|
209
163
|
- spec/inriasuite/abolish
|
210
164
|
- spec/inriasuite/and
|
@@ -273,14 +227,40 @@ files:
|
|
273
227
|
- spec/inriasuite/true
|
274
228
|
- spec/inriasuite/unify
|
275
229
|
- spec/inriasuite_spec.rb
|
276
|
-
- spec/
|
277
|
-
- spec/
|
278
|
-
- spec/
|
279
|
-
- spec/
|
230
|
+
- spec/integration/custom_classes_spec.rb
|
231
|
+
- spec/integration/dsl_spec.rb
|
232
|
+
- spec/integration/recursion_spec.rb
|
233
|
+
- spec/integration/theory_as_module_spec.rb
|
234
|
+
- spec/integration/theory_as_module_with_include_spec.rb
|
235
|
+
- spec/rspec/rubylog_spec.rb
|
236
|
+
- spec/rubylog/assertable_spec.rb
|
237
|
+
- spec/rubylog/builtins/arithmetics_spec.rb
|
238
|
+
- spec/rubylog/builtins/assumption_spec.rb
|
239
|
+
- spec/rubylog/builtins/ensure_spec.rb
|
240
|
+
- spec/rubylog/builtins/file_system_spec.rb
|
241
|
+
- spec/rubylog/builtins/logic_spec.rb
|
242
|
+
- spec/rubylog/builtins/reflection_spec.rb
|
243
|
+
- spec/rubylog/builtins/term_spec.rb
|
244
|
+
- spec/rubylog/context_modules/demonstration_spec.rb
|
245
|
+
- spec/rubylog/context_modules/predicates_spec.rb
|
246
|
+
- spec/rubylog/context_modules/thats_spec.rb
|
247
|
+
- spec/rubylog/dsl/array_splat_spec.rb
|
248
|
+
- spec/rubylog/dsl/primitives_spec.rb
|
249
|
+
- spec/rubylog/errors_spec.rb
|
250
|
+
- spec/rubylog/interfaces/term_spec.rb
|
251
|
+
- spec/rubylog/mixins/array_spec.rb
|
252
|
+
- spec/rubylog/mixins/composite_term_spec.rb
|
253
|
+
- spec/rubylog/mixins/proc_spec.rb
|
254
|
+
- spec/rubylog/mixins/string_spec.rb
|
255
|
+
- spec/rubylog/mixins/symbol_spec.rb
|
256
|
+
- spec/rubylog/structure_spec.rb
|
257
|
+
- spec/rubylog/term_spec.rb
|
258
|
+
- spec/rubylog/tracing_spec.input
|
259
|
+
- spec/rubylog/tracing_spec.rb
|
260
|
+
- spec/rubylog/variable_spec.rb
|
280
261
|
- spec/spec_helper.rb
|
281
|
-
-
|
282
|
-
-
|
283
|
-
- spec/variable_spec.rb
|
262
|
+
- vimrc
|
263
|
+
- README.rdoc.orig
|
284
264
|
homepage: https://github.com/cie/rubylog
|
285
265
|
licenses:
|
286
266
|
- MIT
|
@@ -296,17 +276,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
296
276
|
version: '0'
|
297
277
|
segments:
|
298
278
|
- 0
|
299
|
-
hash:
|
279
|
+
hash: 34493633
|
300
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
301
281
|
none: false
|
302
282
|
requirements:
|
303
|
-
- - ! '
|
283
|
+
- - ! '>'
|
304
284
|
- !ruby/object:Gem::Version
|
305
|
-
version:
|
285
|
+
version: 1.3.1
|
306
286
|
requirements: []
|
307
287
|
rubyforge_project:
|
308
288
|
rubygems_version: 1.8.15
|
309
289
|
signing_key:
|
310
290
|
specification_version: 3
|
311
|
-
summary:
|
291
|
+
summary: A Prolog-like DSL
|
312
292
|
test_files: []
|
data/README.hu.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# Rubylog
|
2
|
-
|
3
|
-
# A Rubylog a Prologhoz hasonló programozási nyelv.
|
4
|
-
|
5
|
-
# A Prolog program alapköve a funktorból és argumentumokból álló term:
|
6
|
-
likes("John", "beer")
|
7
|
-
|
8
|
-
# A Rubylog programban a funktor az első argumentum után áll:
|
9
|
-
"John".likes("beer")
|
10
|
-
|
11
|
-
# A prolog programot tények és szabályok alkotják.
|
12
|
-
likes("John", "beer").
|
13
|
-
drinks(X,D) :- likes(X,D).
|
14
|
-
|
15
|
-
# Rubylogban hasonlóan, a tényeket ! jelzi, a szabályokat 'if'
|
16
|
-
"John".likes! "beer"
|
17
|
-
X.drinks(D).if X.likes(D)
|
18
|
-
|
19
|
-
# A nulláris predikátumok a Rubylogban szimbólumok:
|
20
|
-
:true
|
21
|
-
:fail
|
22
|
-
:cut!
|
23
|
-
|
24
|
-
# A Prolog operátorok helyett Rubylogban sokszor szavakat használunk:
|
25
|
-
# Prolog Rubylog
|
26
|
-
:- if
|
27
|
-
, and
|
28
|
-
; or
|
29
|
-
\+ false
|
30
|
-
= is
|
31
|
-
|
32
|
-
# A jobb hangzás érdekében néhány Prolog beépített predikátum neve más
|
33
|
-
# Rubylogban
|
34
|
-
# Prolog Rubylog
|
35
|
-
member in
|
36
|
-
# HAsonlít de többet tud
|
37
|
-
|
38
|
-
# Vannak
|
39
|
-
all
|
40
|
-
any
|
41
|
-
one
|
42
|
-
none
|
43
|
-
|
44
|
-
# Reflection
|
45
|
-
list structure follows_from
|
46
|
-
|
47
|
-
|
48
|
-
# Azért nem vezettünk be
|
49
|
-
{a:b}.is {a}
|
50
|
-
{}.isnt {a:b}
|
51
|
-
# -t, mert akkor nem lenne kummutatív az unifikáció, és az egyáltalán nem POLA.
|
52
|
-
# Azért nem vezettünk be
|
53
|
-
{a:b}.is {}
|
54
|
-
# -t, mert az nagyon bonyolult, és nem POLA. Ezért marad
|
55
|
-
{a:b}.is {a:b}
|
56
|
-
# és lehet
|
57
|
-
{a:b}.merge!(X)
|
58
|
-
# akár.
|