Skip to content

Commit

Permalink
handle temporal copula reversibility -- can alternatively be handled …
Browse files Browse the repository at this point in the history
…by introducing a new theorem
  • Loading branch information
maxeeem committed Mar 28, 2024
1 parent 17c66b6 commit e36563c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pynars/NARS/Control/Reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,21 @@ def inference_step(self, concept: Concept):
order_mark = Copula.RetrospectiveImplication

stamp = Stamp_merge(stamp_task, stamp_belief, order_mark)

def add_task(term):
sentence_derived = Judgement(term, stamp, truth)
# print(stamp.tense == sentence_derived.stamp.tense)
task_derived = Task(sentence_derived, budget)
# print(task_derived.sentence.tense, task_derived)
# normalize the variable indices
task_derived.term._normalize_variables()
tasks_derived.append(task_derived)

sentence_derived = Judgement(conclusion, stamp, truth)
# print(stamp.tense == sentence_derived.stamp.tense)
task_derived = Task(sentence_derived, budget)
# print(task_derived.sentence.tense, task_derived)
# normalize the variable indices
task_derived.term._normalize_variables()
tasks_derived.append(task_derived)
add_task(conclusion)

if type(conclusion) is Statement: # TODO: handle this better
if conclusion.is_predictive or conclusion.is_retrospective:
add_task(conclusion.temporal_swapped())

if term_link is not None:
for derived_task in tasks_derived:
Expand Down
2 changes: 2 additions & 0 deletions pynars/NARS/InferenceEngine/KanrenEngine/nal-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,5 @@ theorems: |
<(&/, S1, N1, S2) <=> <S2 =\> (&/, S1, N1)>>
<(&/, S1, N1, S2) <=> <S1 =/> S2>>
<(&/, S1, N1, <S2 ==> S3>) <=> <(&/, S1, N1, S2) =/> S3>>
# <<A =/> B> <=> <B =\> A>>
8 changes: 8 additions & 0 deletions pynars/Narsese/_py/Copula.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ def get_retrospective(self):
else:
return self

@property
def get_temporal_swapped(self):
if self == Copula.PredictiveImplication:
return Copula.RetrospectiveImplication
if self == Copula.RetrospectiveImplication:
return Copula.PredictiveImplication
return self

def symmetrize(self):
if self is Copula.Inheritance:
return Copula.Similarity
Expand Down
5 changes: 5 additions & 0 deletions pynars/Narsese/_py/Statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def predictive(self):
def retrospective(self):
return Statement(self.subject, self.copula.get_retrospective, self.predicate)

def temporal_swapped(self):
if self.copula is Copula.PredictiveEquivalence:
return self # TODO: could be handled by introducing <\> copula
return Statement(self.predicate, self.copula.get_temporal_swapped, self.subject)

def clone(self):
if not self.has_var: return self
# now, not self.has_var
Expand Down

0 comments on commit e36563c

Please sign in to comment.