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
  /**
   * Syllogistic rules whose both premises are on the same asymmetric relation
   *
   * @param sentence The taskSentence in the task
   * @param belief The judgment in the belief
   * @param figure The location of the shared term
   * @param memory Reference to the memory
   */
  private static void asymmetricAsymmetric(
      Sentence sentence, Sentence belief, int figure, Memory memory) {
    Statement s1 = (Statement) sentence.cloneContent();
    Statement s2 = (Statement) belief.cloneContent();
    Term t1, t2;
    switch (figure) {
      case 11: // induction
        if (Variable.unify(Symbols.VAR_INDEPENDENT, s1.getSubject(), s2.getSubject(), s1, s2)) {
          if (s1.equals(s2)) {
            return;
          }
          t1 = s2.getPredicate();
          t2 = s1.getPredicate();
          SyllogisticRules.abdIndCom(t1, t2, sentence, belief, figure, memory);
          CompositionalRules.composeCompound(s1, s2, 0, memory);
        }

        break;
      case 12: // deduction
        if (Variable.unify(Symbols.VAR_INDEPENDENT, s1.getSubject(), s2.getPredicate(), s1, s2)) {
          if (s1.equals(s2)) {
            return;
          }
          t1 = s2.getSubject();
          t2 = s1.getPredicate();
          if (Variable.unify(Symbols.VAR_QUERY, t1, t2, s1, s2)) {
            LocalRules.matchReverse(memory);
          } else {
            SyllogisticRules.dedExe(t1, t2, sentence, belief, memory);
          }
        }
        break;
      case 21: // exemplification
        if (Variable.unify(Symbols.VAR_INDEPENDENT, s1.getPredicate(), s2.getSubject(), s1, s2)) {
          if (s1.equals(s2)) {
            return;
          }
          t1 = s1.getSubject();
          t2 = s2.getPredicate();
          if (Variable.unify(Symbols.VAR_QUERY, t1, t2, s1, s2)) {
            LocalRules.matchReverse(memory);
          } else {
            SyllogisticRules.dedExe(t1, t2, sentence, belief, memory);
          }
        }
        break;
      case 22: // abduction
        if (Variable.unify(Symbols.VAR_INDEPENDENT, s1.getPredicate(), s2.getPredicate(), s1, s2)) {
          if (s1.equals(s2)) {
            return;
          }
          t1 = s1.getSubject();
          t2 = s2.getSubject();
          if (!SyllogisticRules.conditionalAbd(
              t1, t2, s1, s2, memory)) { // if conditional abduction, skip the following
            SyllogisticRules.abdIndCom(t1, t2, sentence, belief, figure, memory);
            CompositionalRules.composeCompound(s1, s2, 1, memory);
          }
        }
        break;
      default:
    }
  }