Example #1
0
 /**
  * Inference between a compound term and a statement
  *
  * @param compound The compound term
  * @param index The location of the current term in the compound
  * @param statement The statement
  * @param side The location of the current term in the statement
  * @param beliefTerm The content of the belief
  * @param memory Reference to the memory
  */
 private static void compoundAndStatement(
     CompoundTerm compound,
     short index,
     Statement statement,
     short side,
     Term beliefTerm,
     Memory memory) {
   Term component = compound.componentAt(index);
   Task task = memory.currentTask;
   if (component.getClass() == statement.getClass()) {
     if ((compound instanceof Conjunction) && (memory.currentBelief != null)) {
       if (Variable.unify(Symbols.VAR_DEPENDENT, component, statement, compound, statement)) {
         SyllogisticRules.elimiVarDep(compound, component, statement.equals(beliefTerm), memory);
       } else if (task.getSentence().isJudgment()) {
         CompositionalRules.introVarInner(statement, (Statement) component, compound, memory);
       }
     }
   } else {
     if (!task.isStructural() && task.getSentence().isJudgment()) {
       if (statement instanceof Inheritance) {
         StructuralRules.structuralCompose1(compound, index, statement, memory);
         //                    if (!(compound instanceof SetExt) && !(compound instanceof SetInt))
         // {
         if (!(compound instanceof SetExt
             || compound instanceof SetInt
             || compound instanceof Negation)) {
           StructuralRules.structuralCompose2(compound, index, statement, side, memory);
         } // {A --> B, A @ (A&C)} |- (A&C) --> (B&C)
       } else if ((statement instanceof Similarity) && !(compound instanceof Conjunction)) {
         StructuralRules.structuralCompose2(compound, index, statement, side, memory);
       } // {A <-> B, A @ (A&C)} |- (A&C) <-> (B&C)
     }
   }
 }
Example #2
0
 /**
  * The TaskLink is of type TRANSFORM, and the conclusion is an equivalent transformation
  *
  * @param tLink The task link
  * @param memory Reference to the memory
  */
 public static void transformTask(TaskLink tLink, Memory memory) {
   CompoundTerm content = (CompoundTerm) memory.currentTask.getContent().clone();
   short[] indices = tLink.getIndices();
   Term inh = null;
   if ((indices.length == 2) || (content instanceof Inheritance)) { // <(*, term, #) --> #>
     inh = content;
   } else if (indices.length == 3) { // <<(*, term, #) --> #> ==> #>
     inh = content.componentAt(indices[0]);
   } else if (indices.length == 4) { // <(&&, <(*, term, #) --> #>, #) ==> #>
     Term component = content.componentAt(indices[0]);
     if ((component instanceof Conjunction)
         && (((content instanceof Implication) && (indices[0] == 0))
             || (content instanceof Equivalence))) {
       inh = ((CompoundTerm) component).componentAt(indices[1]);
     } else {
       return;
     }
   }
   if (inh instanceof Inheritance) {
     StructuralRules.transformProductImage((Inheritance) inh, content, indices, memory);
   }
 }
Example #3
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);
 }
Example #4
0
 /**
  * Conditional deduction or induction, with variable unification
  *
  * @param conditional The premise that is an Implication with a Conjunction as condition
  * @param index The location of the shared term in the condition
  * @param statement The second premise that is a statement
  * @param side The location of the shared term in the statement
  * @param memory Reference to the memory
  */
 private static void conditionalDedIndWithVar(
     Implication conditional, short index, Statement statement, short side, Memory memory) {
   CompoundTerm condition = (CompoundTerm) conditional.getSubject();
   Term component = condition.componentAt(index);
   Term component2 = null;
   if (statement instanceof Inheritance) {
     component2 = statement;
     side = -1;
   } else if (statement instanceof Implication) {
     component2 = statement.componentAt(side);
   }
   if ((component2 != null)
       && Variable.unify(Symbols.VAR_INDEPENDENT, component, component2, conditional, statement)) {
     SyllogisticRules.conditionalDedInd(conditional, index, statement, side, memory);
   }
 }