Example #1
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:
    }
  }