Exemple #1
0
 /**
  * {<M ==> S>, <M ==> P>} |- {<S ==> P>,
  *
  * <P ==>S>, <S <=> P>}
  *
  * @param term1 Subject of the first new task
  * @param term2 Predicate of the first new task
  * @param taskSentence The first premise
  * @param belief The second premise
  * @param figure Locations of the shared term in premises
  */
 static void abdIndCom(
     Term term1, Term term2, Sentence taskSentence, Judgment belief, int figure) {
   if (RDFStatement.invalidStatement(term1, term2)) {
     return;
   }
   RDFStatement st1 = (RDFStatement) taskSentence.getContent();
   RDFStatement st2 = (RDFStatement) belief.getContent();
   TruthValue truth1 = null;
   TruthValue truth2 = null;
   TruthValue truth3 = null;
   BudgetValue budget1, budget2, budget3;
   TruthValue value1 = taskSentence.getTruth();
   TruthValue value2 = belief.getTruth();
   if (taskSentence instanceof Question) {
     budget1 = BudgetFunctions.backward(value2);
     budget2 = BudgetFunctions.backwardWeak(value2);
     budget3 = BudgetFunctions.backward(value2);
   } else {
     if (taskSentence instanceof Goal) {
       truth1 = TruthFunctions.desireStrong(value1, value2);
       truth2 = TruthFunctions.desireWeak(value2, value1);
       truth3 = TruthFunctions.desireStrong(value1, value2);
     } else {
       truth1 = TruthFunctions.abduction(value1, value2);
       truth2 = TruthFunctions.abduction(value2, value1);
       truth3 = TruthFunctions.comparison(value1, value2);
     }
     budget1 = BudgetFunctions.forward(truth1);
     budget2 = BudgetFunctions.forward(truth2);
     budget3 = BudgetFunctions.forward(truth3);
   }
   TemporalValue order1 = st1.getOrder();
   TemporalValue order2 = st2.getOrder();
   TemporalValue order = TemporalRules.syllogistic(order1, order2, figure);
   //        if (tense == null) {
   //            tense = TemporalValue.WHEN;
   //            truth1 = TruthFunctions.temporalInduction(truth1);
   //            truth2 = TruthFunctions.temporalInduction(truth2);
   //            truth3 = TruthFunctions.temporalInduction(truth3);
   //        }
   RDFStatement statement1, statement2, statement3;
   statement1 = RDFStatement.make(st1, term1, term2, order);
   statement2 = RDFStatement.make(st1, term2, term1, TemporalValue.getReverse(order));
   statement3 = RDFStatement.makeSym(st1, term1, term2, order);
   Memory.doublePremiseTask(budget1, statement1, truth1);
   Memory.doublePremiseTask(budget2, statement2, truth2);
   Memory.doublePremiseTask(budget3, statement3, truth3);
   if (statement1.isConstant()) {
     Memory.doublePremiseTask(budget1, introVarInd(belief, taskSentence, figure, true), truth1);
     Memory.doublePremiseTask(budget2, introVarInd(taskSentence, belief, figure, true), truth2);
     Memory.doublePremiseTask(budget3, introVarInd(taskSentence, belief, figure, false), truth3);
   }
 }
Exemple #2
0
 /**
  * {<M ==> S>, <M ==> P>} |- {<S ==> P>,
  *
  * <P ==>S>, <S <=> P>}
  *
  * @param task1 The first premise
  * @param task2 The second premise
  * @param order Temporal order of the terms in conclusion
  */
 public static void temporalIndCom(Task task1, Task task2, TemporalValue order) {
   Judgment judg1 = (Judgment) task1.getSentence();
   Judgment judg2 = (Judgment) task2.getSentence();
   Stamp stamp = Stamp.make(judg1.getStamp(), judg2.getStamp());
   if (stamp == null) {
     return;
   }
   Memory.currentStamp = stamp;
   Term term1 = judg1.getContent();
   Term term2 = judg2.getContent();
   if ((term1 instanceof Inheritance) && (term2 instanceof Inheritance)) {
     RDFStatement s1 = (RDFStatement) term1;
     RDFStatement s2 = (RDFStatement) term2;
     Variable var1 = new Variable(Symbols.VARIABLE_TAG + "0");
     Variable var2 = new Variable(Symbols.VARIABLE_TAG + "0");
     if (s1.getSubject().equals(s2.getSubject())) {
       term1 = RDFStatement.make(s1, var1, s1.getPredicate());
       term2 = RDFStatement.make(s2, var2, s2.getPredicate());
     } else if (s1.getPredicate().equals(s2.getPredicate())) {
       term1 = RDFStatement.make(s1, s1.getSubject(), var1);
       term2 = RDFStatement.make(s2, s2.getSubject(), var2);
     }
   } else { // to generalize
     Term condition;
     if ((term1 instanceof Implication) && (term2 instanceof Inheritance)) {
       condition = ((Implication) term1).getSubject();
       if (condition.equals(term2)) {
         return;
       }
       if ((condition instanceof Conjunction)
           && ((Conjunction) condition).containComponent(term2)) {
         return;
       }
     } else if ((term1 instanceof Inheritance) && (term2 instanceof Implication)) {
       condition = ((Implication) term2).getSubject();
       if (condition.equals(term1)) {
         return;
       }
       if ((condition instanceof Conjunction)
           && ((Conjunction) condition).containComponent(term1)) {
         return;
       }
     }
   }
   RDFStatement statement1 = Implication.make(term1, term2, order);
   RDFStatement statement2 = Implication.make(term2, term1, TemporalValue.getReverse(order));
   RDFStatement statement3 = Equivalence.make(term1, term2, order);
   TruthValue value1 = judg1.getTruth();
   TruthValue value2 = judg2.getTruth();
   TruthValue truth1 = TruthFunctions.induction(value1, value2);
   TruthValue truth2 = TruthFunctions.induction(value2, value1);
   TruthValue truth3 = TruthFunctions.comparison(value1, value2);
   BudgetValue budget1 =
       BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth1);
   BudgetValue budget2 =
       BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth2);
   BudgetValue budget3 =
       BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth3);
   Memory.currentTense = new TemporalValue(0);
   Memory.doublePremiseTask(budget1, statement1, truth1);
   Memory.doublePremiseTask(budget2, statement2, truth2);
   Memory.doublePremiseTask(budget3, statement3, truth3);
 }