예제 #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)
     }
   }
 }
예제 #2
0
 /**
  * Inference between a compound term and a component of it
  *
  * @param compound The compound term
  * @param component The component term
  * @param compoundTask Whether the compound comes from the task
  * @param memory Reference to the memory
  */
 private static void compoundAndSelf(
     CompoundTerm compound, Term component, boolean compoundTask, Memory memory) {
   if ((compound instanceof Conjunction) || (compound instanceof Disjunction)) {
     if (memory.currentBelief != null) {
       CompositionalRules.decomposeStatement(compound, component, compoundTask, memory);
     } else if (compound.containComponent(component)) {
       StructuralRules.structuralCompound(compound, component, compoundTask, memory);
     }
   } else if ((compound instanceof Negation) && !memory.currentTask.isStructural()) {
     if (compoundTask) {
       StructuralRules.transformNegation(((Negation) compound).componentAt(0), memory);
     } else {
       StructuralRules.transformNegation(compound, memory);
     }
   }
 }
예제 #3
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);
   }
 }
예제 #4
0
 /**
  * Inference between a component term (of the current 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 memory Reference to the memory
  */
 private static void componentAndStatement(
     CompoundTerm compound, short index, Statement statement, short side, Memory memory) {
   if (!memory.currentTask.isStructural()) {
     if (statement instanceof Inheritance) {
       StructuralRules.structuralDecompose1(compound, index, statement, memory);
       if (!(compound instanceof SetExt) && !(compound instanceof SetInt)) {
         StructuralRules.structuralDecompose2(
             statement, memory); // {(C-B) --> (C-A), A @ (C-A)} |- A --> B
       } else {
         StructuralRules.transformSetRelation(compound, statement, side, memory);
       }
     } else if (statement instanceof Similarity) {
       StructuralRules.structuralDecompose2(
           statement, memory); // {(C-B) --> (C-A), A @ (C-A)} |- A --> B
       if ((compound instanceof SetExt) || (compound instanceof SetInt)) {
         StructuralRules.transformSetRelation(compound, statement, side, memory);
       }
     } else if ((statement instanceof Implication) && (compound instanceof Negation)) {
       StructuralRules.contraposition(statement, memory);
     }
   }
 }