From cb220d45c3ed1c94877dd135c107364db43d2e3e Mon Sep 17 00:00:00 2001 From: Patrick Hammer <patham9@gmail.com> Date: Wed, 11 Apr 2018 08:07:54 -0400 Subject: [PATCH] Always keep task time, if a rule just matches in one direction the other will be made working. RuleTables: Similarity case accepts SetExt and SetInt --- nal/test/nal7.15.nal | 6 +++--- nal/test/nal7.18.nal | 4 ++-- nal/test/nal7.19.nal | 4 ++-- nal/test/nal7.2.nal | 4 ++-- nars_core/nars/inference/CompositionalRules.java | 2 +- nars_core/nars/inference/RuleTables.java | 3 +-- nars_core/nars/inference/SyllogisticRules.java | 15 +++++++-------- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/nal/test/nal7.15.nal b/nal/test/nal7.15.nal index 002d0a478f..ebc174cea2 100644 --- a/nal/test/nal7.15.nal +++ b/nal/test/nal7.15.nal @@ -1,5 +1,5 @@ '********** temporal analogy - IN: <<(*, $x, door_101) --> open> =/> <(*, $x, room_101) --> enter>>. %0.95% - IN: <<(*, $x, room_101) --> enter> <=> <(*, $x, corridor_100) --> leave>>. +<<(*, $x, door_101) --> open> =/> <(*, $x, room_101) --> enter>>. %0.95% +<<(*, $x, room_101) --> enter> <|> <(*, $x, corridor_100) --> leave>>. 40 -''outputMustContain('<<door_101 --> (/,open,$1,_)> =/> <(*,$1,corridor_100) --> leave>>. %0.95;0.81%') +''outputMustContain('<<(*,$1,door_101) --> open> =/> <(*,$1,corridor_100) --> leave>>. %0.95;0.81%') diff --git a/nal/test/nal7.18.nal b/nal/test/nal7.18.nal index 9f313f37e2..da3c1fa608 100644 --- a/nal/test/nal7.18.nal +++ b/nal/test/nal7.18.nal @@ -1,6 +1,6 @@ '********** inference on tense - IN: <(&/,<(*, $x, key_101) --> hold>,+1) =/> <(*, $x, room_101) --> enter>>. - IN: <(*, John, key_101) --> hold>. :\: +<(&/,<(*, $x, key_101) --> hold>,+1) =/> <(*, $x, room_101) --> enter>>. +<(*, John, key_101) --> hold>. :\: 210 ''outputMustContain('<(*,John,room_101) --> enter>. :\: %1.00;0.81%') diff --git a/nal/test/nal7.19.nal b/nal/test/nal7.19.nal index d2d9a77e7b..a222e18ef3 100644 --- a/nal/test/nal7.19.nal +++ b/nal/test/nal7.19.nal @@ -1,5 +1,5 @@ '********** inference on tense - IN: <(&/,<(*, $x, key_101) --> hold>,+1) =/> <(*, $x, room_101) --> enter>>. - IN: <(*,John,room_101) --> enter>. :|: +<(&/,<(*, $x, key_101) --> hold>,+1) =/> <(*, $x, room_101) --> enter>>. +<(*,John,room_101) --> enter>. :|: 15 ''outputMustContain('<(*,John,key_101) --> hold>. :\: %1.00;0.45%') diff --git a/nal/test/nal7.2.nal b/nal/test/nal7.2.nal index fcc3bc4d4a..517e799bb7 100644 --- a/nal/test/nal7.2.nal +++ b/nal/test/nal7.2.nal @@ -1,8 +1,8 @@ '********** inference on tense - IN: <<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. +<<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. - IN: <(*,John,key_101) --> hold>. :|: +<(*,John,key_101) --> hold>. :|: 20 diff --git a/nars_core/nars/inference/CompositionalRules.java b/nars_core/nars/inference/CompositionalRules.java index 64858e97de..5110b15df1 100644 --- a/nars_core/nars/inference/CompositionalRules.java +++ b/nars_core/nars/inference/CompositionalRules.java @@ -297,7 +297,7 @@ public final class CompositionalRules { if (isTemporalConjunction && (compound.getTemporalOrder() == TemporalRules.ORDER_FORWARD) && (index != 0)) { return; } - long occurrence_time = nal.getTheNewStamp().getOccurrenceTime(); + long occurrence_time = nal.getCurrentTask().sentence.getOccurenceTime(); if(isTemporalConjunction && (compound.getTemporalOrder() == TemporalRules.ORDER_FORWARD)) { if(!nal.getCurrentTask().sentence.isEternal() && compound.term[index + 1] instanceof Interval) { long shift_occurrence = ((Interval)compound.term[index + 1]).time; diff --git a/nars_core/nars/inference/RuleTables.java b/nars_core/nars/inference/RuleTables.java index a896c74e19..1506bc6934 100644 --- a/nars_core/nars/inference/RuleTables.java +++ b/nars_core/nars/inference/RuleTables.java @@ -833,8 +833,7 @@ public class RuleTables { || compound instanceof Conjunction || compound instanceof Disjunction)) { StructuralRules.structuralCompose2(compound, index, statement, side, nal); } // {A --> B, A @ (A&C)} |- (A&C) --> (B&C) - } else if (!(compound instanceof SetExt || compound instanceof SetInt || compound instanceof Negation - || compound instanceof Conjunction || compound instanceof Disjunction)) { + } else if (!(compound instanceof Negation || compound instanceof Conjunction || compound instanceof Disjunction)) { StructuralRules.structuralCompose2(compound, index, statement, side, nal); } // {A <-> B, A @ (A&C)} |- (A&C) <-> (B&C) } diff --git a/nars_core/nars/inference/SyllogisticRules.java b/nars_core/nars/inference/SyllogisticRules.java index 33bdb7bf5a..2f1ba89cb2 100644 --- a/nars_core/nars/inference/SyllogisticRules.java +++ b/nars_core/nars/inference/SyllogisticRules.java @@ -181,13 +181,13 @@ public final class SyllogisticRules { return true; //no need for other syllogistic inference, it were sensational terms, } //but it would not hurt to allow it either.. but why afford tasks that summarize //so little evidence in comparison to the amount summarized by the array comparison. - long occurrence_time2 = nal.getTheNewStamp().getOccurrenceTime(); + long occurrence_time2 = nal.getCurrentTask().sentence.getOccurenceTime(); while (occurrence_time2!=Stamp.ETERNAL && (term2 instanceof Conjunction) && (((CompoundTerm) term2).term[0] instanceof Interval)) { Interval interval = (Interval) ((CompoundTerm) term2).term[0]; occurrence_time2 += interval.time; term2 = ((CompoundTerm)term2).setComponent(0, null, nal.mem()); } - long occurrence_time1 = nal.getTheNewStamp().getOccurrenceTime(); + long occurrence_time1 = nal.getCurrentTask().sentence.getOccurenceTime(); while (occurrence_time1!=Stamp.ETERNAL && (term1 instanceof Conjunction) && (((CompoundTerm) term1).term[0] instanceof Interval)) { Interval interval = (Interval) ((CompoundTerm) term1).term[0]; occurrence_time1 += interval.time; @@ -431,14 +431,13 @@ public final class SyllogisticRules { return; int order = statement.getTemporalOrder(); - long occurrence_time = nal.getTheNewStamp().getOccurrenceTime(); + long occurrence_time = nal.getCurrentTask().sentence.getOccurenceTime(); if ((order != ORDER_NONE) && (order!=ORDER_INVALID)) { long baseTime = subSentence.getOccurenceTime(); - if (baseTime == Stamp.ETERNAL) { // =/> always should produce events - baseTime = nal.getTime(); + if (baseTime != Stamp.ETERNAL) { + long inc = order * Parameters.DURATION; + occurrence_time = (side == 0) ? baseTime+inc : baseTime-inc; } - long inc = order * Parameters.DURATION; - occurrence_time = (side == 0) ? baseTime+inc : baseTime-inc; } TruthValue beliefTruth = beliefSentence.truth; @@ -608,7 +607,7 @@ public final class SyllogisticRules { if (content == null) return; - long occurrence_time = nal.getTheNewStamp().getOccurrenceTime(); + long occurrence_time = nal.getCurrentTask().sentence.getOccurenceTime(); if (delta != 0) { long baseTime = taskSentence.getOccurenceTime(); if (baseTime != Stamp.ETERNAL) { -- GitLab