Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Kanren2 #17

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Tests/test_NAL/test_NAL1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import Tests.utils_for_test as utils_for_test
from Tests.utils_for_test import *

import logging

# utils_for_test.engine = RuleMap()

class TEST_NAL1(unittest.TestCase):
Expand Down Expand Up @@ -164,7 +166,13 @@ def test_exemplification(self):
self.assertTrue(
output_contains(tasks_derived, '<animal --> robin>. %1.00;0.45%')
)


# Set log level
logging.basicConfig()
log = logging.getLogger("LOG")
results = kanren.inference(task.sentence, belief.sentence)
log.warning(results)

pass


Expand Down
1 change: 0 additions & 1 deletion Tests/utils_for_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
nars = Reasoner(100, 100)
engine: GeneralEngine = nars.inference


def process_two_premises(premise1: str, premise2: str, n_cycle: int) -> List[Task]:
''''''
tasks_all_cycles = []
Expand Down
5 changes: 3 additions & 2 deletions pynars/NARS/Control/Reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pynars.Narsese._py.Statement import Statement
from pynars.Narsese._py.Task import Belief
from ..DataStructures import Bag, Memory, NarseseChannel, Buffer, Task, Concept
from ..InferenceEngine import GeneralEngine, TemporalEngine, VariableEngine
from ..InferenceEngine import GeneralEngine, TemporalEngine, VariableEngine, KanrenEngine
from pynars import Config
from pynars.Config import Enable
from typing import Callable, List, Tuple, Union
Expand All @@ -24,7 +24,8 @@ def __init__(self, n_memory, capacity, config = './config.json', nal_rules={1,2,
# print('''Init...''')
Config.load(config)

self.inference = GeneralEngine(add_rules=nal_rules)
self.inference = KanrenEngine()
# self.inference = GeneralEngine(add_rules=nal_rules)
self.variable_inference = VariableEngine(add_rules=nal_rules)
self.temporal_inference = TemporalEngine(add_rules=nal_rules) # for temporal causal reasoning

Expand Down
3 changes: 3 additions & 0 deletions pynars/NARS/InferenceEngine/GeneralEngine/GeneralEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ def step(self, concept: Concept):
term_belief = concept_target.term
# if belief is None: continue

# if belief is not None:
# print(">>", task.term, belief.term)

# before matching and applying the rules, do variable-related processes (i.e. unification, and substitution/introduction/elimination)
subst, elimn, intro = GeneralEngine.unify(task.term, belief.term if belief is not None else None, concept.term, task_link_valid, term_link)
task_subst, task_elimn, task_intro = GeneralEngine.substitute(subst, elimn, intro, task)
Expand Down
Loading
Loading