示例#1
0
 /**
  * {<M --> S>, <C ==> <M --> P>>} |- <(&&, <#x --> S>, C) ==> <#x --> P>> {<M --> S>, (&&, C, <M
  * --> P>)} |- (&&, C, <<#x --> S> ==> <#x --> P>>)
  *
  * @param premise1 The first premise directly used in internal induction, <M --> S>
  * @param premise2 The component to be used as a premise in internal induction, <M --> P>
  * @param oldCompound The whole content of the first premise, Implication or Conjunction
  */
 static void introVarIndInner(
     RDFStatement premise1, RDFStatement premise2, CompoundTerm oldCompound) {
   Task task = Memory.currentTask;
   Sentence taskSentence = task.getSentence();
   if (!taskSentence.isJudgment()) {
     return;
   }
   if (premise1.getClass() != premise2.getClass()) {
     return;
   }
   Variable var1 = new Variable(Symbols.VARIABLE_TAG + "0");
   Variable var2 = new Variable(Symbols.VARIABLE_TAG + "0");
   RDFStatement state1, state2;
   if (premise1.getSubject().equals(premise2.getSubject())) {
     state1 = RDFStatement.make(premise1, var1, premise1.getPredicate());
     state2 = RDFStatement.make(premise2, var2, premise2.getPredicate());
   } else if (premise1.getPredicate().equals(premise2.getPredicate())) {
     state1 = RDFStatement.make(premise1, premise1.getSubject(), var1);
     state2 = RDFStatement.make(premise2, premise2.getSubject(), var2);
   } else {
     return;
   }
   Sentence belief = Memory.currentBelief;
   Term compound, content;
   TemporalValue tense;
   TruthValue truth;
   if (premise1.equals(taskSentence.getContent())) {
     truth = TruthFunctions.abduction(taskSentence.getTruth(), belief.getTruth());
     tense = TemporalRules.tenseInduction(taskSentence.getTense(), belief.getTense());
   } else {
     truth = TruthFunctions.abduction(belief.getTruth(), taskSentence.getTruth());
     tense = TemporalRules.tenseInduction(belief.getTense(), taskSentence.getTense());
   }
   if (tense == null) {
     return;
   }
   if ((oldCompound instanceof Implication) && (tense == oldCompound.getOrder())) {
     compound = RDFStatement.make((RDFStatement) oldCompound, oldCompound.componentAt(0), state2);
     content = RDFStatement.make((RDFStatement) oldCompound, state1, compound);
   } else if (oldCompound instanceof Conjunction) {
     compound = Implication.make(state1, state2, tense);
     content = CompoundTerm.replaceComponent(oldCompound, premise2, compound);
   } else {
     return;
   }
   BudgetValue budget = BudgetFunctions.forward(truth);
   Memory.doublePremiseTask(budget, content, truth);
 }
示例#2
0
 /**
  * {<M --> S>, <M --> P>} |- <<#x --> S> ==> <#x --> P>> {<M --> S>, <M --> P>} |- <<#x --> S> <=>
  * <#x --> P>>
  *
  * @param sentence1 The first premise <M --> S>
  * @param sentence2 The second premise <M --> P>
  * @param figure The figure indicating the location of the shared term
  * @param isImplication The conclusion is Implication, not Equivalence
  */
 private static RDFStatement introVarInd(
     Sentence sentence1, Sentence sentence2, int figure, boolean isImplication) {
   RDFStatement premise1 = (RDFStatement) sentence1.getContent();
   RDFStatement premise2 = (RDFStatement) sentence2.getContent();
   RDFStatement state1, state2;
   Variable v1 = new Variable(Symbols.VARIABLE_TAG + "0");
   Variable v2 = new Variable(Symbols.VARIABLE_TAG + "0");
   if (figure == 11) {
     state1 = RDFStatement.make(premise1, v1, premise1.getPredicate());
     state2 = RDFStatement.make(premise2, v2, premise2.getPredicate());
   } else {
     state1 = RDFStatement.make(premise1, premise1.getSubject(), v1);
     state2 = RDFStatement.make(premise2, premise2.getSubject(), v2);
   }
   TemporalValue tense1 = sentence1.getTense();
   TemporalValue tense2 = sentence2.getTense();
   TemporalValue tense = TemporalRules.tenseInduction(tense1, tense2);
   if (tense == null) {
     return null;
   }
   RDFStatement content;
   if (isImplication) {
     content = Implication.make(state1, state2, tense);
   } else {
     content = Equivalence.make(state1, state2, tense);
   }
   return content;
 }