porolog 1.0.0 → 1.0.1

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.
@@ -68,7 +68,7 @@ module Porolog
68
68
 
69
69
  # Creates a fact rule that states that these arguments do not satisfy the Predicate.
70
70
  # @return [Porolog::Arguments] the Arguments
71
- def falicy!
71
+ def fallacy!
72
72
  @predicate << Rule.new(self, false)
73
73
  self
74
74
  end
@@ -82,7 +82,7 @@ module Porolog
82
82
 
83
83
  # Creates a fact rule that states that these arguments do not satisfy the Predicate and terminates solving the predicate.
84
84
  # @return [Porolog::Arguments] the Arguments
85
- def cut_falicy!
85
+ def cut_fallacy!
86
86
  @predicate << Rule.new(self, [:CUT, false])
87
87
  self
88
88
  end
@@ -116,7 +116,7 @@ module Porolog
116
116
  subgoal.log << "CUTTING #{goal.inspect}..."
117
117
  result = true
118
118
  if conjunction.empty?
119
- block.call(subgoal)
119
+ !goal.terminated? && block.call(subgoal)
120
120
  else
121
121
  result = satisfy_conjunction(goal, subgoal, conjunction, &block)
122
122
  end
@@ -132,7 +132,7 @@ module Porolog
132
132
  return false
133
133
 
134
134
  when nil
135
- block.call(subgoal)
135
+ !goal.terminated? && block.call(subgoal)
136
136
  return true
137
137
  end
138
138
 
@@ -145,16 +145,16 @@ module Porolog
145
145
  unified && subsubgoal.satisfy() do
146
146
  result = true
147
147
  if conjunction.empty?
148
- block.call(goal)
148
+ !goal.terminated? && block.call(goal)
149
149
  else
150
- result = satisfy_conjunction(goal, subsubgoal, conjunction, &block)
150
+ result = !goal.terminated? && satisfy_conjunction(goal, subsubgoal, conjunction, &block)
151
151
  end
152
152
  end
153
153
 
154
154
  # -- Uninstantiate --
155
155
  subsubgoal.delete!
156
156
 
157
- result
157
+ result && !goal.terminated?
158
158
  end
159
159
 
160
160
  end
@@ -166,12 +166,12 @@ describe 'Porolog' do
166
166
 
167
167
  end
168
168
 
169
- describe '#falicy!' do
169
+ describe '#fallacy!' do
170
170
 
171
- it 'should create a falicy for its predicate' do
171
+ it 'should create a fallacy for its predicate' do
172
172
  arguments1 = pred.(1,'a',0.1)
173
173
 
174
- arguments1.falicy!
174
+ arguments1.fallacy!
175
175
 
176
176
  assert_equal '[ pred(1,"a",0.1):- false]', pred.rules.inspect
177
177
  end
@@ -190,12 +190,12 @@ describe 'Porolog' do
190
190
 
191
191
  end
192
192
 
193
- describe '#cut_falicy!' do
193
+ describe '#cut_fallacy!' do
194
194
 
195
- it 'should create a falicy for its predicate and terminate solving the goal' do
195
+ it 'should create a fallacy for its predicate and terminate solving the goal' do
196
196
  arguments1 = pred.(1,'a',0.1)
197
197
 
198
- arguments1.cut_falicy!
198
+ arguments1.cut_fallacy!
199
199
 
200
200
  assert_equal '[ pred(1,"a",0.1):- [:CUT, false]]', pred.rules.inspect
201
201
  end
@@ -772,10 +772,10 @@ describe 'Porolog' do
772
772
  refute f(3).valid?, name
773
773
  end
774
774
 
775
- it 'should return false when a falicy is found' do
775
+ it 'should return false when a fallacy is found' do
776
776
  predicate :f
777
777
 
778
- f(3).falicy!
778
+ f(3).fallacy!
779
779
 
780
780
  refute f(3).valid?, name
781
781
  end
@@ -644,10 +644,10 @@ describe 'Porolog' do
644
644
  assert_equal [{}], solutions
645
645
  end
646
646
 
647
- it 'should not solve a falicy' do
647
+ it 'should not solve a fallacy' do
648
648
  predicate :fact
649
649
 
650
- fact(42).falicy!
650
+ fact(42).fallacy!
651
651
 
652
652
  solutions = fact(42).solve
653
653
 
@@ -393,31 +393,31 @@ describe 'Porolog' do
393
393
 
394
394
  describe '#noteq' do
395
395
 
396
- it 'should return no solutions when given unequal values' do
396
+ it 'should return a solution when given unequal values' do
397
397
  builtin :noteq
398
398
 
399
399
  assert_solutions noteq([3,2,1,4], [1,2,3,4]), [{}]
400
400
  end
401
401
 
402
- it 'should return a solution when given equal values' do
402
+ it 'should return no solutions when given equal values' do
403
403
  builtin :noteq
404
404
 
405
405
  assert_solutions noteq([1,2,3,4], [1,2,3,4]), []
406
406
  end
407
407
 
408
- it 'should return a solution with an unbound variable when given the same unbound variable' do
408
+ it 'should return no solutions with an unbound variable when given the same unbound variable' do
409
409
  builtin :noteq
410
410
 
411
411
  assert_solutions noteq(:X, :X), []
412
412
  end
413
413
 
414
- it 'should return no solutions when given two unbound variables' do
414
+ it 'should return a solution when given two unbound variables' do
415
415
  builtin :noteq
416
416
 
417
417
  assert_solutions noteq(:X, :Y), [{ X: nil, Y: nil }]
418
418
  end
419
419
 
420
- it 'should return one solution with unbound variables when given given two uninstantiated variables that are bound to each other' do
420
+ it 'should return no solutions with unbound variables when given given two uninstantiated variables that are bound to each other' do
421
421
  builtin :noteq, :is
422
422
  predicate :bind_and_noteq
423
423
 
@@ -429,7 +429,7 @@ describe 'Porolog' do
429
429
  assert_solutions bind_and_noteq(:X, :Y), []
430
430
  end
431
431
 
432
- it 'should return no solutions when given two uninstantiated variables that are not bound to each other' do
432
+ it 'should return a solution when given two uninstantiated variables that are not bound to each other' do
433
433
  builtin :noteq, :is
434
434
  predicate :bind_and_noteq
435
435
 
@@ -254,10 +254,10 @@ describe 'Porolog' do
254
254
  assert_Predicate alpha, :alpha, [alpha.rules.first]
255
255
  end
256
256
 
257
- it 'should add new falicies to a predicate' do
257
+ it 'should add new fallacies to a predicate' do
258
258
  alpha = Predicate.new 'alpha'
259
259
 
260
- alpha.('p','q').falicy!
260
+ alpha.('p','q').fallacy!
261
261
 
262
262
  assert_equal 1, alpha.rules.size
263
263
  assert_equal false, alpha.rules.first.definition
@@ -120,7 +120,7 @@ describe 'Porolog' do
120
120
 
121
121
  same(:X,:X).fact!
122
122
 
123
- not_same(:X,:X).cut_falicy!
123
+ not_same(:X,:X).cut_fallacy!
124
124
  not_same(:X,:Y).fact!
125
125
 
126
126
  (1..5).to_a.each_cons(2) do |left, right|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: porolog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Esteban
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-02 00:00:00.000000000 Z
11
+ date: 2020-08-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Implements a Prolog inference engine using Plain Old Ruby Objects
14
14
  email: