Skip to content

Commit

Permalink
working on fixing additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxeeem committed Mar 26, 2024
1 parent 3cc8950 commit c430dd2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 23 deletions.
16 changes: 8 additions & 8 deletions Tests/test_NAL/test_NAL2.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_structure_transformation_0(self):
tasks_derived = process_two_premises(
'<bright <-> smart>. %0.90;0.90%',
'<[smart] --> [bright]>?',
20
500
)
self.assertTrue(
output_contains(tasks_derived, '<[bright] <-> [smart]>. %0.90;0.81%')
Expand Down Expand Up @@ -328,7 +328,7 @@ def test_conversions_between_inheritance_and_similarity_1(self):
tasks_derived = process_two_premises(
'<swan --> bird>. %0.90;0.90%',
'<bird <-> swan>?',
10
100
)
self.assertTrue(
output_contains(tasks_derived, '<bird <-> swan>. %0.90;0.47%')
Expand All @@ -355,10 +355,10 @@ def test_conversions_between_inheritance_and_similarity_2(self):
tasks_derived = process_two_premises(
'<bird <-> swan>. %0.90;0.90%',
'<swan --> bird>?',
100
200
)
self.assertTrue(
output_contains(tasks_derived, '<swan --> bird>. %0.90;0.73%')
output_contains(tasks_derived, '<swan --> bird>. %0.90;0.81%')
)
pass

Expand Down Expand Up @@ -444,7 +444,7 @@ def test_set_definition_0(self):
tasks_derived = process_two_premises(
'<{Tweety} --> {Birdie}>. %1.00;0.90%',
None,
100
200
)
self.assertTrue(
output_contains(tasks_derived, '<{Birdie} <-> {Tweety}>. %1.00;0.90%')
Expand All @@ -467,7 +467,7 @@ def test_set_definition_1(self):
tasks_derived = process_two_premises(
'<[smart] --> [bright]>. %1.00;0.90%',
None,
100
200
)
self.assertTrue(
output_contains(tasks_derived, '<[bright] <-> [smart]>. %1.00;0.90%')
Expand All @@ -493,7 +493,7 @@ def test_set_definition_2(self):
tasks_derived = process_two_premises(
'<{Birdie} <-> {Tweety}>. %1.00;0.90%',
None,
100
200
)
self.assertTrue(
output_contains(tasks_derived, '<Birdie <-> Tweety>. %1.00;0.90%')
Expand Down Expand Up @@ -522,7 +522,7 @@ def test_set_definition_3(self):
tasks_derived = process_two_premises(
'<[bright] <-> [smart]>. %1.00;0.90%',
None,
100
200
)
self.assertTrue(
output_contains(tasks_derived, '<bright <-> smart>. %1.00;0.90%')
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_NAL/test_NAL4.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_structural_transformation_5(self):
tasks_derived = process_two_premises(
'<(\,neutralization,_,base) --> acid>. %1.00;0.90%',
None,
400
100
)

self.assertTrue(
Expand Down
12 changes: 6 additions & 6 deletions Tests/test_NAL/test_NAL5.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,21 +962,21 @@ def test_conditional_induction_compose(self):
pass

def test_question_0(self):
rules, task, belief, concept, task_link, term_link, result1, result2 = rule_map_two_premises(
tasks_derived = process_two_premises(
'(&&, A, B)?',
'A.',
'A.', is_belief_term=True)
tasks_derived = [rule(task, belief.term, task_link, term_link) for rule in rules]
10
)
self.assertTrue(
output_contains(tasks_derived, 'A?')
)

def test_question_1(self):
rules, task, belief, concept, task_link, term_link, result1, result2 = rule_map_two_premises(
tasks_derived = process_two_premises(
'C?',
'<(&&, A, B)==>C>.',
'C.')
tasks_derived = [rule(task, belief, task_link, term_link) for rule in rules]
10
)
self.assertTrue(
output_contains(tasks_derived, '(&&, A, B)?')
)
Expand Down
21 changes: 13 additions & 8 deletions pynars/NARS/Control/Reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pynars.Narsese._py.Sentence import Judgement, Stamp, Tense, Question
from pynars.Narsese._py.Statement import Statement
from pynars.Narsese._py.Task import Belief
from pynars.Narsese._py.Evidence import Base
from pynars.Narsese import Copula, Item
from ..DataStructures import Bag, Memory, NarseseChannel, Buffer, Task, Concept, EventBuffer
from ..InferenceEngine import GeneralEngine, TemporalEngine, VariableEngine, KanrenEngine
Expand Down Expand Up @@ -360,10 +361,12 @@ def inference_step(self, concept: Concept):

for term, truth in results:
# TODO: how to properly handle stamp for immediate rules?
stamp_task: Stamp = task.stamp
# base = Base((Global.get_input_id(),))
# stamp_task: Stamp = Stamp(Global.time, None, None, base)
stamp_task = task.stamp

if task.is_question:
question_derived = Question(term[0], task.stamp)
question_derived = Question(term[0], stamp_task)
task_derived = Task(question_derived)
# set flag to prevent repeated processing
task_derived.immediate_rules_applied = True
Expand Down Expand Up @@ -473,7 +476,7 @@ def inference_step(self, concept: Concept):

if belief is None:
continue

if task == belief:
# if task.sentence.punct == belief.sentence.punct:
# is_revision = revisible(task, belief)
Expand Down Expand Up @@ -502,11 +505,13 @@ def inference_step(self, concept: Concept):

results = []

# # COMPOSITIONAL
# res, cached = self.inference.inference_compositional(task.sentence, belief.sentence)

# if not cached:
# results.extend(res)
# COMPOSITIONAL
if task.is_eternal and belief.is_eternal:
# events are handled in the event buffer
res, cached = self.inference.inference_compositional(task.sentence, belief.sentence)

if not cached:
results.extend(res)

# Temporal Projection and Eternalization
if belief is not None:
Expand Down
7 changes: 7 additions & 0 deletions pynars/NARS/InferenceEngine/KanrenEngine/nal-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ theorems: |
<<T2 --> (/, R, T1, _)> <=> <(T1 * T2) --> R>>
<<R --> (T1 * T2)> <=> <(\, R, _, T2) --> T1>>
<<R --> (T1 * T2)> <=> <(\, R, T1, _) --> T2>>
<<(\, R, _, T2) --> T1> <=> <R --> (T1 * T2)>>
<<(\, R, T1, _) --> T2> <=> <R --> (T1 * T2)>>
<<S1 ==> <S2 ==> S3>> <=> <(S1 && S2) ==> S3>>
Expand All @@ -226,6 +228,11 @@ theorems: |
<<T2 --> (/, R, T1, _)> <=> <T1 --> (/, R, _, T2)>>
<<T1 --> (\, R, _, T2)> <=> <T2 --> (\, R, T1, _)>>
<<T2 --> (\, R, T1, _)> <=> <T1 --> (\, R, _, T2)>>
# 'inverse of the above
<<(/, R, _, T2) --> T1> <=> <(/, R, T1, _) --> T2>>
<<(/, R, T1, _) --> T2> <=> <(/, R, _, T2) --> T1>>
<<(\, R, _, T2) --> T1> <=> <(\, R, T1, _) --> T2>>
<<(\, R, T1, _) --> T2> <=> <(\, R, _, T2) --> T1>>
<(&/, S1, N1, S2) <=> <S2 =\> (&/, S1, N1)>>
<(&/, S1, N1, S2) <=> <S1 =/> S2>>
Expand Down

0 comments on commit c430dd2

Please sign in to comment.