Esempio n. 1
0
 /**
  * {<S <=> M>, <M <=> P>} |- <S <=> P>
  *
  * @param term1 Subject of the new task
  * @param term2 Predicate of the new task
  * @param belief The first premise
  * @param sentence The second premise
  * @param figure Locations of the shared term in premises
  */
 static void resemblance(Term term1, Term term2, Judgment belief, Sentence sentence, int figure) {
   if (RDFStatement.invalidStatement(term1, term2)) {
     return;
   }
   RDFStatement st1 = (RDFStatement) belief.getContent();
   RDFStatement st2 = (RDFStatement) sentence.getContent();
   TruthValue truth = null;
   BudgetValue budget;
   Task task = Memory.currentTask;
   if (sentence instanceof Question) {
     budget = BudgetFunctions.backward(belief.getTruth());
   } else {
     if (sentence instanceof Goal) {
       truth = TruthFunctions.desireStrong(sentence.getTruth(), belief.getTruth());
     } else {
       truth = TruthFunctions.resemblance(belief.getTruth(), sentence.getTruth());
     }
     budget = BudgetFunctions.forward(truth);
   }
   TemporalValue order1 = st1.getOrder();
   TemporalValue order2 = st2.getOrder();
   TemporalValue order = TemporalRules.syllogistic(order1, order2, figure);
   Term statement = RDFStatement.make(st1, term1, term2, order);
   Memory.doublePremiseTask(budget, statement, truth);
 }
Esempio n. 2
0
 /**
  * {<S ==> M>, <M ==> P>} |- {<S ==> P>,
  *
  * <P ==>S>}
  *
  * @param term1 Subject of the first new task
  * @param term2 Predicate of the first new task
  * @param sentence The first premise
  * @param belief The second premise
  */
 static void dedExe(Term term1, Term term2, Sentence sentence, Judgment belief) {
   if (RDFStatement.invalidStatement(term1, term2)) {
     return;
   }
   TruthValue value1 = sentence.getTruth();
   TruthValue value2 = belief.getTruth();
   TruthValue truth1 = null;
   TruthValue truth2 = null;
   BudgetValue budget1, budget2;
   if (sentence instanceof Question) {
     budget1 = BudgetFunctions.backwardWeak(value2);
     budget2 = BudgetFunctions.backwardWeak(value2);
   } else {
     if (sentence instanceof Goal) {
       truth1 = TruthFunctions.desireWeak(value1, value2);
       truth2 = TruthFunctions.desireWeak(value1, value2);
     } else {
       truth1 = TruthFunctions.deduction(value1, value2);
       truth2 = TruthFunctions.exemplification(value1, value2);
     }
     budget1 = BudgetFunctions.forward(truth1);
     budget2 = BudgetFunctions.forward(truth2);
   }
   TemporalValue order1 = sentence.getContent().getOrder();
   TemporalValue order2 = belief.getContent().getOrder();
   TemporalValue order = TemporalRules.syllogistic(order1, order2);
   RDFStatement content1 =
       RDFStatement.make((RDFStatement) sentence.getContent(), term1, term2, order);
   RDFStatement content2 =
       RDFStatement.make(
           (RDFStatement) sentence.getContent(), term2, term1, TemporalValue.getReverse(order));
   Memory.doublePremiseTask(budget1, content1, truth1);
   Memory.doublePremiseTask(budget2, content2, truth2);
 }
Esempio n. 3
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);
   }
 }
Esempio n. 4
0
 /**
  * {<S ==> P>, <M <=> P>} |- <S ==> P>
  *
  * @param term1 Subject of the new task
  * @param term2 Predicate of the new task
  * @param asym The asymmetric premise
  * @param sym The symmetric premise
  * @param figure Locations of the shared term in premises
  */
 static void analogy(Term term1, Term term2, Sentence asym, Sentence sym, int figure) {
   if (RDFStatement.invalidStatement(term1, term2)) {
     return;
   }
   RDFStatement asymSt = (RDFStatement) asym.getContent();
   RDFStatement symSt = (RDFStatement) sym.getContent();
   TruthValue truth = null;
   BudgetValue budget;
   Sentence sentence = Memory.currentTask.getSentence();
   CompoundTerm taskTerm = (CompoundTerm) sentence.getContent();
   if (sentence instanceof Question) {
     if (taskTerm.isCommutative()) {
       budget = BudgetFunctions.backwardWeak(asym.getTruth());
     } else {
       budget = BudgetFunctions.backward(sym.getTruth());
     }
   } else {
     if (sentence instanceof Goal) {
       if (taskTerm.isCommutative()) {
         truth = TruthFunctions.desireWeak(asym.getTruth(), sym.getTruth());
       } else {
         truth = TruthFunctions.desireStrong(asym.getTruth(), sym.getTruth());
       }
     } else {
       truth = TruthFunctions.analogy(asym.getTruth(), sym.getTruth());
     }
     budget = BudgetFunctions.forward(truth);
   }
   TemporalValue order1 = asymSt.getOrder();
   TemporalValue order2 = symSt.getOrder();
   TemporalValue order;
   switch (figure) {
     case 11:
     case 12:
       order = TemporalRules.syllogistic(order2, order1, figure);
       break;
     case 21:
     case 22:
       order = TemporalRules.syllogistic(order1, order2, figure);
       break;
     default:
       return;
   }
   Term content = RDFStatement.make(asymSt, term1, term2, order);
   Memory.doublePremiseTask(budget, content, truth);
 }