Esempio n. 1
0
 public int countConstantTerms() {
   int ctr = 0;
   for (@NotNull Term term : terms) {
     if (term.isConstant()) {
       ctr++;
     }
   }
   return ctr;
 }
Esempio n. 2
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);
       }
     }
   }
 }