/** * {<(&&, S2, S3) ==> P>, <(&&, S1, S3) ==> P>} |- <S1 ==> S2> * * @param cond1 The condition of the first premise * @param cond2 The condition of the second premise * @param st1 The first premise * @param st2 The second premise * @return Whether there are derived tasks */ static boolean conditionalAbd(Term cond1, Term cond2, RDFStatement st1, RDFStatement st2) { if (!(st1 instanceof Implication) || !(st2 instanceof Implication)) { return false; } if (!(cond1 instanceof Conjunction) && !(cond2 instanceof Conjunction)) { return false; } TemporalValue order1 = st1.getOrder(); TemporalValue order2 = st2.getOrder(); if (order1 != order2) { return false; } Term term1 = null; Term term2 = null; if (cond1 instanceof Conjunction) { term1 = CompoundTerm.reduceComponents((Conjunction) cond1, cond2); } if (cond2 instanceof Conjunction) { term2 = CompoundTerm.reduceComponents((Conjunction) cond2, cond1); } if ((term1 == null) && (term2 == null)) { return false; } Task task = Memory.currentTask; Sentence sentence = task.getSentence(); Judgment belief = Memory.currentBelief; TruthValue value1 = sentence.getTruth(); TruthValue value2 = belief.getTruth(); boolean keepOrder = (Variable.findSubstitute(Variable.VarType.INDEPENDENT, st1, task.getContent()) != null); Term content; TruthValue truth = null; BudgetValue budget; if (term1 != null) { if (term2 != null) { content = RDFStatement.make(st2, term2, term1, order2); } else { content = term1; } if (sentence instanceof Question) { budget = BudgetFunctions.backwardWeak(value2); } else { if (sentence instanceof Goal) { if (keepOrder) { truth = TruthFunctions.desireDed(value1, value2); } else { truth = TruthFunctions.desireInd(value1, value2); } } else { truth = TruthFunctions.abduction(value2, value1); } budget = BudgetFunctions.forward(truth); } Memory.doublePremiseTask(budget, content, truth); } if (term2 != null) { if (term1 != null) { content = RDFStatement.make(st1, term1, term2, order1); } else { content = term2; } if (sentence instanceof Question) { budget = BudgetFunctions.backwardWeak(value2); } else { if (sentence instanceof Goal) { if (keepOrder) { truth = TruthFunctions.desireDed(value1, value2); } else { truth = TruthFunctions.desireInd(value1, value2); } } else { truth = TruthFunctions.abduction(value1, value2); } budget = BudgetFunctions.forward(truth); } Memory.currentTense = null; Memory.doublePremiseTask(budget, content, truth); } return true; }