Skip to content

Commit

Permalink
Merge pull request #55 from bowen-xu/bug/#48
Browse files Browse the repository at this point in the history
Bug Fix (Backward inference)
  • Loading branch information
maxeeem authored Nov 14, 2023
2 parents 4729b92 + 68aefd6 commit 97e26f4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
#flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with unittest
run: |
python -m unittest discover Tests/test_NAL/ -p "test_*.py"
python -m unittest discover Tests/test_NAL/ -p "test_*.py" -v
14 changes: 7 additions & 7 deletions Tests/test_NAL/test_NAL4.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_structural_transformation_0(self):
tasks_derived = process_two_premises(
'<(*,acid, base) --> reaction>. %1.00;0.90%',
None,
6
10
)

self.assertTrue(
Expand Down Expand Up @@ -69,7 +69,7 @@ def test_structural_transformation_1(self):
tasks_derived = process_two_premises(
'<acid --> (/,reaction,_,base)>. %1.00;0.90%',
None,
6
10
)

self.assertTrue(
Expand All @@ -93,7 +93,7 @@ def test_structural_transformation_2(self):
tasks_derived = process_two_premises(
'<acid --> (/,reaction,_,base)>. %1.00;0.90%',
None,
6
10
)

self.assertTrue(
Expand All @@ -117,7 +117,7 @@ def test_structural_transformation_3(self):
tasks_derived = process_two_premises(
'<base --> (/,reaction,acid,_)>. %1.00;0.90%',
None,
6
10
)

self.assertTrue(
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_structural_transformation_5(self):
tasks_derived = process_two_premises(
'<(\,neutralization,_,base) --> acid>. %1.00;0.90%',
None,
6
10
)

self.assertTrue(
Expand All @@ -189,7 +189,7 @@ def test_structural_transformation_6(self):
tasks_derived = process_two_premises(
'<(\,neutralization,acid,_) --> base>. %1.00;0.90%',
None,
6
10
)

self.assertTrue(
Expand All @@ -213,7 +213,7 @@ def test_structural_transformation_7(self):
tasks_derived = process_two_premises(
'<(\,neutralization,acid,_) --> base>. %1.00;0.90%',
None,
6
10
)

self.assertTrue(
Expand Down
8 changes: 4 additions & 4 deletions Tests/test_NAL/test_NAL5.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def test_conditional_analogy(self):
tasks_derived = process_two_premises(
'<robin --> bird>. %1.00;0.90%',
'<<robin --> bird> <=> <robin --> [flying]>>. %0.80;0.90%',
6
10
)
self.assertTrue(
output_contains(tasks_derived, '<robin --> [flying]>. %0.80;0.65%')
Expand All @@ -349,7 +349,7 @@ def test_conditional_analogy(self):
tasks_derived = process_two_premises(
'<<robin --> bird> <=> <robin --> [flying]>>. %0.80;0.90%',
'<robin --> bird>. %1.00;0.90%',
6
10
)
self.assertTrue(
output_contains(tasks_derived, '<robin --> [flying]>. %0.80;0.65%')
Expand All @@ -358,7 +358,7 @@ def test_conditional_analogy(self):
tasks_derived = process_two_premises(
'<robin --> bird>. %1.00;0.90%',
'<<robin --> [flying]> <=> <robin --> bird>>. %0.80;0.90%',
6
10
)
self.assertTrue(
output_contains(tasks_derived, '<robin --> [flying]>. %0.80;0.65%')
Expand All @@ -368,7 +368,7 @@ def test_conditional_analogy(self):
tasks_derived = process_two_premises(
'<<robin --> [flying]> <=> <robin --> bird>>. %0.80;0.90%',
'<robin --> bird>. %1.00;0.90%',
6
10
)
self.assertTrue(
output_contains(tasks_derived, '<robin --> [flying]>. %0.80;0.65%')
Expand Down
22 changes: 11 additions & 11 deletions Tests/test_NAL/test_NAL6.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_unification_0(self):
tasks_derived = process_two_premises(
'<<$x --> bird> ==> <$x --> flyer>>. %1.00;0.90%',
'<<$y --> bird> ==> <$y --> flyer>>. %0.00;0.70%',
2
20
)
self.assertTrue(
output_contains(tasks_derived, '<<$1 --> bird> ==> <$1 --> flyer>>. %0.79;0.92%')
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_unification_1(self):
tasks_derived = process_two_premises(
'<<$x --> bird> ==> <$x --> animal>>. %1.00;0.90%',
'<<$y --> robin> ==> <$y --> bird>>. %1.00;0.90%',
10
20
)
self.assertTrue(
output_contains(tasks_derived, '<<$0 --> robin> ==> <$0 --> animal>>. %1.00;0.81%')
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_unification_2(self):
tasks_derived = process_two_premises(
'<<$x --> swan> ==> <$x --> bird>>. %1.00;0.80% ',
'<<$y --> swan> ==> <$y --> swimmer>>. %0.80;0.90%',
10
20
)

self.assertTrue(
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_unification_3(self):
tasks_derived = process_two_premises(
'<<bird --> $x> ==> <robin --> $x>>. %1.00;0.90%',
'<<swimmer --> $y> ==> <robin --> $y>>. %0.70;0.90%',
10
20
)

self.assertTrue(
Expand Down Expand Up @@ -194,7 +194,7 @@ def test_unification_4(self):
tasks_derived = process_two_premises(
'<(&&,<$x --> flyer>,<$x --> [chirping]>) ==> <$x --> bird>>. %1.00;0.90%',
'<<$y --> [with_wings]> ==> <$y --> flyer>>. %1.00;0.90%',
10
20
)

self.assertTrue(
Expand Down Expand Up @@ -225,7 +225,7 @@ def test_unification_5(self):
tasks_derived = process_two_premises(
'<(&&,<$x --> flyer>,<$x --> [chirping]>, <(*, $x, worms) --> food>) ==> <$x --> bird>>. %1.00;0.90%',
'<(&&,<$x --> [chirping]>,<$x --> [with_wings]>) ==> <$x --> bird>>. %1.00;0.90%',
10
20
)

self.assertTrue(
Expand Down Expand Up @@ -267,7 +267,7 @@ def test_unification_6(self):
tasks_derived = process_two_premises(
'<(&&,<$x --> flyer>,<(*,$x,worms) --> food>) ==> <$x --> bird>>. %1.00;0.90%',
'<<$y --> flyer> ==> <$y --> [with_wings]>>. %1.00;0.90%',
10
20
)

self.assertTrue(
Expand Down Expand Up @@ -556,7 +556,7 @@ def test_multiple_variable_elimination_2(self):
tasks_derived = process_two_premises(
'(&&,<#x --> (/,open,#y,_)>,<#x --> lock>,<#y --> key>).',
'<{lock1} --> lock>.',
10
100
)

self.assertTrue(
Expand Down Expand Up @@ -842,7 +842,7 @@ def test_second_level_variable_unification_1(self):
tasks_derived = process_two_premises(
'<<$1 --> lock> ==> (&&,<#2 --> key>,<$1 --> (/,open,#2,_)>)>. %1.00;0.90%',
'<{key1} --> key>. %1.00;0.90% ',
10
100
)

self.assertTrue(
Expand Down Expand Up @@ -924,7 +924,7 @@ def test_variable_elimination_deduction_0(self):
tasks_derived = process_two_premises(
'<(&&,<#1 --> A>, <#1 --> B>) ==> C>. %1.00;0.90%',
'<M --> A>. %1.00;0.90%',
10
100
)

self.assertTrue(
Expand Down Expand Up @@ -984,7 +984,7 @@ def test_abduction_with_variable_elimination_abduction_0(self):
tasks_derived = process_two_premises(
'<(&&,<#1 --> A>,<#1 --> B>) ==> C>. %1.00;0.90%',
'<<M --> A> ==> C>. %1.00;0.90%',
100
150
)

self.assertTrue(
Expand Down
3 changes: 2 additions & 1 deletion pynars/NARS/InferenceEngine/GeneralEngine/GeneralEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def match(cls, task: Task, belief: Belief, term_belief: Term, task_link, term_li
if task == belief:
if task.sentence.punct == belief.sentence.punct:
is_revision = revisible(task, belief)
elif task.term.equal(belief.term):
elif task.term.identical(belief.term):
# elif task.term.equal(belief.term):
# TODO: here
pass
elif not belief.evidential_base.is_overlaped(task.evidential_base):
Expand Down

0 comments on commit 97e26f4

Please sign in to comment.