From 0734e9b6079e07b2d04b22e53a1d2a9386777fca Mon Sep 17 00:00:00 2001
From: patham9 <patham9@91dfdad4-c543-0410-b26a-7d79dded8189>
Date: Sun, 27 Jul 2014 14:40:23 +0000
Subject: [PATCH] finally a simple solution for the second case of issue30

---
 nars_core_java/nars/inference/RuleTables.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/nars_core_java/nars/inference/RuleTables.java b/nars_core_java/nars/inference/RuleTables.java
index c9eb419..3660ed1 100644
--- a/nars_core_java/nars/inference/RuleTables.java
+++ b/nars_core_java/nars/inference/RuleTables.java
@@ -31,6 +31,7 @@ import nars.storage.Memory;
  * to the relevant inference rules.
  */
 public class RuleTables {
+
     /**
      * Entry point of the inference engine
      *
@@ -43,6 +44,13 @@ public class RuleTables {
         Sentence taskSentence = task.getSentence();
         Term taskTerm = (Term) taskSentence.getContent().clone();         // cloning for substitution
         Term beliefTerm = (Term) bLink.getTarget().clone();       // cloning for substitution
+        if(taskTerm instanceof Statement && taskSentence.isJudgment()) {
+            double n=taskTerm.getComplexity(); //don't let this rule apply every time, make it dependent on complexity
+            double w=1.0/((n*(n-1))/2.0); //let's assume hierachical tuple (triangle numbers) amount for this
+            if(CompositionalRules.rand.nextDouble()<w) { //so that NARS memory will not be spammed with contrapositions
+                StructuralRules.contraposition((Statement) taskTerm, taskSentence, memory); //before it was the linkage which did that
+            } //now we some sort "emulate" it.
+        }
         if(CompoundTerm.EqualSubTermsInRespectToImageAndProduct(taskTerm,beliefTerm)) {
            return;
         }
@@ -586,13 +594,13 @@ public class RuleTables {
             if ((compound instanceof SetExt) || (compound instanceof SetInt)) {
                 StructuralRules.transformSetRelation(compound, statement, side, memory);
             }
-        } else if ((statement instanceof Implication) && (compound instanceof Negation)) {
+        } /*else if ((statement instanceof Implication) && (compound instanceof Negation)) {
             if (index == 0) {
                 StructuralRules.contraposition(statement, memory.currentTask.getSentence(), memory);
             } else {
                 StructuralRules.contraposition(statement, memory.currentBelief, memory);
             }
-        }
+        }*/
 //        }
     }
 
-- 
GitLab