示例#1
0
 /**
  * Syllogistic rules whose both premises are on the same symmetric relation
  *
  * @param belief The premise that comes from a belief
  * @param taskSentence The premise that comes from a task
  * @param figure The location of the shared term
  * @param memory Reference to the memory
  */
 private static void symmetricSymmetric(
     Sentence belief, Sentence taskSentence, int figure, Memory memory) {
   Statement s1 = (Statement) belief.cloneContent();
   Statement s2 = (Statement) taskSentence.cloneContent();
   switch (figure) {
     case 11:
       if (Variable.unify(Symbols.VAR_INDEPENDENT, s1.getSubject(), s2.getSubject(), s1, s2)) {
         SyllogisticRules.resemblance(
             s1.getPredicate(), s2.getPredicate(), belief, taskSentence, figure, memory);
       }
       break;
     case 12:
       if (Variable.unify(Symbols.VAR_INDEPENDENT, s1.getSubject(), s2.getPredicate(), s1, s2)) {
         SyllogisticRules.resemblance(
             s1.getPredicate(), s2.getSubject(), belief, taskSentence, figure, memory);
       }
       break;
     case 21:
       if (Variable.unify(Symbols.VAR_INDEPENDENT, s1.getPredicate(), s2.getSubject(), s1, s2)) {
         SyllogisticRules.resemblance(
             s1.getSubject(), s2.getPredicate(), belief, taskSentence, figure, memory);
       }
       break;
     case 22:
       if (Variable.unify(Symbols.VAR_INDEPENDENT, s1.getPredicate(), s2.getPredicate(), s1, s2)) {
         SyllogisticRules.resemblance(
             s1.getSubject(), s2.getSubject(), belief, taskSentence, figure, memory);
       }
       break;
   }
 }
示例#2
0
 /**
  * Syllogistic rules whose first premise is on an asymmetric relation, and the second on a
  * symmetric relation
  *
  * @param asym The asymmetric premise
  * @param sym The symmetric premise
  * @param figure The location of the shared term
  * @param memory Reference to the memory
  */
 private static void asymmetricSymmetric(Sentence asym, Sentence sym, int figure, Memory memory) {
   Statement asymSt = (Statement) asym.cloneContent();
   Statement symSt = (Statement) sym.cloneContent();
   Term t1, t2;
   switch (figure) {
     case 11:
       if (Variable.unify(
           Symbols.VAR_INDEPENDENT, asymSt.getSubject(), symSt.getSubject(), asymSt, symSt)) {
         t1 = asymSt.getPredicate();
         t2 = symSt.getPredicate();
         if (Variable.unify(Symbols.VAR_QUERY, t1, t2, asymSt, symSt)) {
           LocalRules.matchAsymSym(asym, sym, figure, memory);
         } else {
           SyllogisticRules.analogy(t2, t1, asym, sym, figure, memory);
         }
       }
       break;
     case 12:
       if (Variable.unify(
           Symbols.VAR_INDEPENDENT, asymSt.getSubject(), symSt.getPredicate(), asymSt, symSt)) {
         t1 = asymSt.getPredicate();
         t2 = symSt.getSubject();
         if (Variable.unify(Symbols.VAR_QUERY, t1, t2, asymSt, symSt)) {
           LocalRules.matchAsymSym(asym, sym, figure, memory);
         } else {
           SyllogisticRules.analogy(t2, t1, asym, sym, figure, memory);
         }
       }
       break;
     case 21:
       if (Variable.unify(
           Symbols.VAR_INDEPENDENT, asymSt.getPredicate(), symSt.getSubject(), asymSt, symSt)) {
         t1 = asymSt.getSubject();
         t2 = symSt.getPredicate();
         if (Variable.unify(Symbols.VAR_QUERY, t1, t2, asymSt, symSt)) {
           LocalRules.matchAsymSym(asym, sym, figure, memory);
         } else {
           SyllogisticRules.analogy(t1, t2, asym, sym, figure, memory);
         }
       }
       break;
     case 22:
       if (Variable.unify(
           Symbols.VAR_INDEPENDENT, asymSt.getPredicate(), symSt.getPredicate(), asymSt, symSt)) {
         t1 = asymSt.getSubject();
         t2 = symSt.getSubject();
         if (Variable.unify(Symbols.VAR_QUERY, t1, t2, asymSt, symSt)) {
           LocalRules.matchAsymSym(asym, sym, figure, memory);
         } else {
           SyllogisticRules.analogy(t1, t2, asym, sym, figure, memory);
         }
       }
       break;
   }
 }
示例#3
0
 /**
  * The detachment rule, with variable unification
  *
  * @param originalMainSentence The premise that is an Implication or Equivalence
  * @param subSentence The premise that is the subject or predicate of the first one
  * @param index The location of the second premise in the first
  * @param memory Reference to the memory
  */
 private static void detachmentWithVar(
     Sentence originalMainSentence, Sentence subSentence, int index, Memory memory) {
   Sentence mainSentence = (Sentence) originalMainSentence.clone(); // for substitution
   Statement statement = (Statement) mainSentence.getContent();
   Term component = statement.componentAt(index);
   Term content = subSentence.getContent();
   if ((component instanceof Inheritance) && (memory.currentBelief != null)) {
     if (component.isConstant()) {
       SyllogisticRules.detachment(mainSentence, subSentence, index, memory);
     } else if (Variable.unify(Symbols.VAR_INDEPENDENT, component, content, statement, content)) {
       SyllogisticRules.detachment(mainSentence, subSentence, index, memory);
     } else if ((statement instanceof Implication)
         && (statement.getPredicate() instanceof Statement)
         && (memory.currentTask.getSentence().isJudgment())) {
       Statement s2 = (Statement) statement.getPredicate();
       if (s2.getSubject().equals(((Statement) content).getSubject())) {
         CompositionalRules.introVarInner((Statement) content, s2, statement, memory);
       }
     }
   }
 }
示例#4
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:
    }
  }