Skip to content

Commit

Permalink
v0.0.2 pre-alpha: most of the testacses of nal7, except those relatei…
Browse files Browse the repository at this point in the history
…ve to nal6, have been passed.
  • Loading branch information
xubowen committed Feb 19, 2022
1 parent dd5a5c7 commit 4f95b13
Show file tree
Hide file tree
Showing 87 changed files with 2,775 additions and 1,318 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ __pycache__/
*$py.class
Tests/*.png
*.pkl
./utils/SparseLUT
!pynars/utils/SparseLUT/*.pyd
temp/
# C extensions
*.so
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@
"module": "pynars.Console",
"console": "integratedTerminal",
"args": [
"Tests/examples/single_step/nal7/nal7.7.nal"
"Tests/examples/single_step/nal7/nal7.revrev.nal"
// "Tests/examples/single_step/nal5.query.nal"
]
},
{
"name": "Python: _generate_init_file",
"type": "python",
"request": "launch",
"module": "NAL._generate_init_file"
"module": "pynars.NAL._generate_init_file"
},
{
"name": "Python: Parser test",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Reference:
- Python version: 3.7.10.
- Only tested under this version, however, Python 3.7 and higher versions maybe acceptable.
- OS: Windows 10.
- Only tested under this OS, however, other OS might be ok.
- Only tested under this OS, however, other OSs might be ok.
- Packages Requirements: see `requirements.txt`.
- It is noted that the version of the python package `tqdm` should be no higher than 3.1.4, otherwise the color display would be abnormal. This is because of a bug of `tqdm`, which leads to conflicts between `sty` and `tqdm` and cause unexpected color display of `sty`. However, this constraints is not necessary, i.e., higher version of `tqdm` is ok if you don't mind abnormal display occuring. The abnormal case only occur when you first run the PyNARS when SparseLUT (Sparse Look-Up Table) is built.
- It is noted that the version of the python package `tqdm` should be no higher than 3.1.4, otherwise the color display would be abnormal. This is because of a bug of `tqdm`, which leads to conflicts between `sty` and `tqdm` and cause unexpected color display of `sty`. However, this constraints is not necessary, i.e., higher version of `tqdm` is ok if you don't mind abnormal display occuring. The abnormal case only occurs if you first run PyNARS when SparseLUT (Sparse Look-Up Table) is built.

#### Installation

Expand Down
12 changes: 12 additions & 0 deletions Tests/examples/single_step/nal7.36.1.nal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'********** deduction with interval summation

' a + 1 = b
<(&/, a, +1) =/> (&/, b, c)>.

' b + 1 = c
<(&/, b, c, +1) =/> d>.

10

' a + 2 = c
''outputMustContain('<(&/,a,+2) =/> d>. %1.00;0.81%')
12 changes: 12 additions & 0 deletions Tests/examples/single_step/nal7.36.2.nal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'********** deduction with interval summation

' a + 1 = b
<(&/, a, +1) =/> (&/, b, c)>.

' b + 1 = c
<(&/, c, b, +1) =/> d>.

10

' a + 2 = c
''outputMustNotContain('<(&/,a,+2) =/> d>. %1.00;0.81%')
14 changes: 14 additions & 0 deletions Tests/examples/single_step/nal7/nal7.18.const.nal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'********** inference on tense

'If someone hold key_101, he will enter room_101 (in 100 steps)
<(&/,<(*, John, key_101) --> hold>,+100) =/> <(*, John, room_101) --> enter>>.

'John held the key_101
<(*, John, key_101) --> hold>. :\:

20

'John will enter room_101
''outputMustContain('<(*,John,room_101) --> enter>. :!95: %1.00;0.81%')

'this one is working, but throws an exception
File renamed without changes.
12 changes: 12 additions & 0 deletions Tests/examples/single_step/nal7/nal7.19.const.nal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'********** inference on tense

'If someone hold key_101, he will enter room_101 (in 100 steps)
<(&/,<(*, John, key_101) --> hold>,+100) =/> <(*, John, room_101) --> enter>>.

'John is entering room_101 now
<(*,John,room_101) --> enter>. :|:

25

'John held the key_101 (105 steps before)
''outputMustContain('<(*,John,key_101) --> hold>. :!-105: %1.00;0.45%')
File renamed without changes.
2 changes: 1 addition & 1 deletion Tests/examples/single_step/nal7/nal7.3.nal
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'John entered room_101
<(*,John,room_101) --> enter>. :\: %1.00;0.90%

3
10

''outputMustContain('<(*,John,key_101) --> hold>. :!-10: %1.00;0.45%')

18 changes: 18 additions & 0 deletions Tests/examples/single_step/nal7/nal7.6.const.nal
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'********** induction on events

'John is opening door_101
<John --> (/,open,_,door_101)>. :|:

6

'John is entering room_101
<John --> (/,enter,_,room_101)>. :|:

20

'If John enter room_101, he should open door_101 before
''outputMustContain('<<John --> (/,enter,_,room_101)> =\> (&/,<John --> (/,open,_,door_101)>,+6)>. :!6: %1.00;0.45%')

'adjusted +2 to +3 in both conditions

10
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

20

'If John enter room_101, he should open door_101 before
''outputMustContain('<<John --> (/,enter,_,room_101)> =\> (&/,<John --> (/,open,_,door_101)>,+6)>. :!6: %1.00;0.45%')

'new: variable introduction also in time:

'If someone enter room_101, he should open door_101 before
Expand Down
2 changes: 2 additions & 0 deletions Tests/examples/single_step/nal7/nal7.concurrentEqual.res.nal
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
<A <|> B>.
<B <|> C>.

5

''outputMustContain('<A <|> C>. %1.00;0.81%')
8 changes: 5 additions & 3 deletions Tests/examples/single_step/nal7/nal7.concurrentImpl.abd.nal
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
' (A =|> B), (A =|> C) |- (B =|> C) (Truth:Abduction)
' (A =|> B), (C =|> B) |- (A =|> C) (Truth:Induction)

<A =|> B>.
<A =|> C>.
<C =|> B>.

''outputMustContain('<B =|> C>. %1.00;0.45%')
5

''outputMustContain('<A =|> C>. %1.00;0.45%')
2 changes: 2 additions & 0 deletions Tests/examples/single_step/nal7/nal7.concurrentImpl.ded.nal
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
<A =|> B>.
<B =|> C>.

5

''outputMustContain('<A =|> C>. %1.00;0.81%')
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<<something --> [hardened]> =|> <something --> [unscrewing]>>. %1.00;0.90%
<something --> [unscrewing]>!

15

''outputMustContain('<something --> [hardened]>! %1.00;0.81%')
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<<$1 --> [hardened]> =|> <$1 --> [unscrewing]>>. %1.00;0.90%
<#1 --> [unscrewing]>!

10
15

''outputMustContain('<#1 --> [hardened]>! %1.00;0.81%')
8 changes: 5 additions & 3 deletions Tests/examples/single_step/nal7/nal7.concurrentImpl.ind.nal
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
' (A =|> B), (C =|> B) |- (A =|> C) (Truth:Induction)
' (A =|> B), (A =|> C) |- (B =|> C) (Truth:Abduction)

<A =|> B>.
<C =|> B>.
<A =|> C>.

''outputMustContain('<A =|> C>. %1.00;0.45%')
5

''outputMustContain('<B =|> C>. %1.00;0.45%')
2 changes: 1 addition & 1 deletion Tests/examples/single_step/nal7/nal7.eventInduction2.nal
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'John is opening door_101 now
<(*,John,door_101) --> open>. :|:

6
60

'John is entering room_101 now
<(*,John,room_101) --> enter>. :|:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<<something --> [hardened]> =/> <something --> [unscrewing]>>. %1.00;0.90%
<something --> [unscrewing]>!

15

''outputMustContain('<something --> [hardened]>! %1.00;0.81%')
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<<$1 --> [hardened]> =/> <$1 --> [unscrewing]>>. %1.00;0.90%
<#1 --> [unscrewing]>!

10
15

''outputMustContain('<#1 --> [hardened]>! %1.00;0.81%')
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<<something --> [unscrewing]> =\> <something --> [hardened]>>. %1.00;0.90%
<something --> [unscrewing]>!

10

''outputMustContain('<something --> [hardened]>! %1.00;0.45%')
7 changes: 3 additions & 4 deletions Tests/test_NAL/test_BUG_NAL4.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import NARS
from pynars import NARS, Narsese
import unittest

from pynars.NARS.DataStructures import Bag, Task, Concept, Table
from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink
from pynars.Narsese import Judgement, Term, Statement, Copula, Truth

from pathlib import Path
import Narsese
from pynars.Narsese import Compound, Connector
from pynars.NAL.MetaLevelInference.VariableSubstitution import *
from pynars.Narsese import VarPrefix, Variable
from pynars.NARS.RuleMap import RuleMap_v2
from pynars.NARS import Reasoner_3_0_4 as Reasoner
from pynars.NARS.RuleMap import RuleMap
from pynars.NARS import Reasoner as Reasoner

import Tests.utils_for_test as utils_for_test
from Tests.utils_for_test import *
Expand Down
9 changes: 4 additions & 5 deletions Tests/test_NAL/test_NAL1.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import NARS
from pynars import NARS, Narsese
import unittest

from pynars.NARS.DataStructures import Bag, Task, Concept, Table
from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink
from pynars.Narsese import Judgement, Term, Statement, Copula, Truth

from pathlib import Path
import Narsese
from pynars.Narsese import Compound, Connector
from pynars.NAL.MetaLevelInference.VariableSubstitution import *
from pynars.Narsese import VarPrefix, Variable
from pynars.NARS.RuleMap import RuleMap_v2
from pynars.NARS import Reasoner_3_0_4 as Reasoner
from pynars.NARS.RuleMap import RuleMap
from pynars.NARS import Reasoner as Reasoner

import Tests.utils_for_test as utils_for_test
from Tests.utils_for_test import *

utils_for_test.rule_map = RuleMap_v2()
utils_for_test.engine = RuleMap()

class TEST_NAL1(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_NAL/test_NAL2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

import Narsese
from pynars import Narsese
from pynars.NAL.MetaLevelInference.VariableSubstitution import *

from Tests.utils_for_test import *
Expand Down
7 changes: 3 additions & 4 deletions Tests/test_NAL/test_NAL3.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import NARS
from pynars import NARS, Narsese
import unittest

from pynars.NARS.DataStructures import Bag, Task, Concept, Table
from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink
from pynars.Narsese import Judgement, Term, Statement, Copula, Truth

from pathlib import Path
import Narsese
from pynars.Narsese import Compound, Connector
from pynars.NAL.MetaLevelInference.VariableSubstitution import *
from pynars.Narsese import VarPrefix, Variable
from pynars.NARS.RuleMap import RuleMap_v2
from pynars.NARS import Reasoner_3_0_4 as Reasoner
from pynars.NARS.RuleMap import RuleMap
from pynars.NARS import Reasoner as Reasoner

import Tests.utils_for_test as utils_for_test
from Tests.utils_for_test import *
Expand Down
7 changes: 3 additions & 4 deletions Tests/test_NAL/test_NAL4.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import NARS
from pynars import NARS, Narsese
import unittest

from pynars.NARS.DataStructures import Bag, Task, Concept, Table
from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink
from pynars.Narsese import Judgement, Term, Statement, Copula, Truth

from pathlib import Path
import Narsese
from pynars.Narsese import Compound, Connector
from pynars.NAL.MetaLevelInference.VariableSubstitution import *
from pynars.Narsese import VarPrefix, Variable
from pynars.NARS.RuleMap import RuleMap_v2
from pynars.NARS import Reasoner_3_0_4 as Reasoner
from pynars.NARS.RuleMap import RuleMap
from pynars.NARS import Reasoner as Reasoner

import Tests.utils_for_test as utils_for_test
from Tests.utils_for_test import *
Expand Down
7 changes: 3 additions & 4 deletions Tests/test_NAL/test_NAL5.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import unittest
from pathlib import Path

import NARS
import Narsese
from pynars import NARS, Narsese
import Tests.utils_for_test as utils_for_test
from pynars.NAL.MetaLevelInference.VariableSubstitution import *
from pynars.NARS import Reasoner_3_0_4 as Reasoner
from pynars.NARS import Reasoner as Reasoner
from pynars.NARS.DataStructures import Bag, Concept, Table, Task
from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink
from pynars.NARS.RuleMap import RuleMap_v2
from pynars.NARS.RuleMap import RuleMap
from pynars.Narsese import (Compound, Connector, Copula, Judgement, Statement, Term,
Truth, Variable, VarPrefix)
from Tests.utils_for_test import *
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_NAL/test_NAL6.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pynars.NARS.DataStructures import Task
from pynars.NAL.MetaLevelInference.VariableSubstitution import *
from pynars.NARS.RuleMap import RuleMap_v2
from pynars.NARS.RuleMap import RuleMap

import Tests.utils_for_test as utils_for_test
from Tests.utils_for_test import *
Expand Down
Loading

0 comments on commit 4f95b13

Please sign in to comment.