/** * Conditional deduction or induction, with variable unification * * @param conditional The premise that is an Implication with a Conjunction as condition * @param index The location of the shared term in the condition * @param statement The second premise that is a statement * @param side The location of the shared term in the statement * @param memory Reference to the memory */ private static void conditionalDedIndWithVar( Implication conditional, short index, Statement statement, short side, Memory memory) { CompoundTerm condition = (CompoundTerm) conditional.getSubject(); Term component = condition.componentAt(index); Term component2 = null; if (statement instanceof Inheritance) { component2 = statement; side = -1; } else if (statement instanceof Implication) { component2 = statement.componentAt(side); } if ((component2 != null) && Variable.unify(Symbols.VAR_INDEPENDENT, component, component2, conditional, statement)) { SyllogisticRules.conditionalDedInd(conditional, index, statement, side, memory); } }
/** * 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); } } } }