Search in sources :

Example 6 with CompoundTerm

use of nars.language.CompoundTerm in project opennars by opennars.

the class InheritanceGraph method add.

@Override
public boolean add(Sentence s, CompoundTerm ct, Item c) {
    if (ct instanceof Statement) {
        Statement st = (Statement) ct;
        Term subject = st.getSubject();
        Term predicate = st.getPredicate();
        addVertex(subject);
        addVertex(predicate);
        System.out.println(subject.toString().trim() + " " + predicate.toString().trim() + " " + s.truth.getExpectation() + s.truth.getFrequency() + " " + s.truth.getConfidence() + " " + " Inheritance");
        addEdge(subject, predicate, s);
        return true;
    }
    return false;
}
Also used : Statement(nars.language.Statement) CompoundTerm(nars.language.CompoundTerm) Term(nars.language.Term)

Example 7 with CompoundTerm

use of nars.language.CompoundTerm in project opennars by opennars.

the class CompositionalRules method introVarInner.

/**
 * {<M --> S>, <C ==> <M --> P>>} |- <(&&, <#x --> S>, C) ==> <#x --> P>>
 * {<M --> S>, (&&, C, <M --> P>)} |- (&&, C, <<#x --> S> ==> <#x --> P>>)
 *
 * @param taskContent The first premise directly used in internal induction,
 * <M --> S>
 * @param beliefContent The componentCommon to be used as a premise in
 * internal induction, <M --> P>
 * @param oldCompound The whole contentInd of the first premise, Implication
 * or Conjunction
 * @param nal Reference to the memory
 */
static boolean introVarInner(Statement premise1, Statement premise2, CompoundTerm oldCompound, DerivationContext nal) {
    Task task = nal.getCurrentTask();
    Sentence taskSentence = task.sentence;
    if (!taskSentence.isJudgment() || (premise1.getClass() != premise2.getClass()) || oldCompound.containsTerm(premise1)) {
        return false;
    }
    Term subject1 = premise1.getSubject();
    Term subject2 = premise2.getSubject();
    Term predicate1 = premise1.getPredicate();
    Term predicate2 = premise2.getPredicate();
    Term commonTerm1, commonTerm2;
    if (subject1.equals(subject2)) {
        commonTerm1 = subject1;
        commonTerm2 = secondCommonTerm(predicate1, predicate2, 0);
    } else if (predicate1.equals(predicate2)) {
        commonTerm1 = predicate1;
        commonTerm2 = secondCommonTerm(subject1, subject2, 0);
    } else {
        return false;
    }
    Sentence belief = nal.getCurrentBelief();
    HashMap<Term, Term> substitute = new HashMap<>();
    boolean b1 = false, b2 = false;
    {
        Variable varDep2 = new Variable("#varDep2");
        Term content = Conjunction.make(premise1, oldCompound);
        if (!(content instanceof CompoundTerm))
            return false;
        substitute.put(commonTerm1, varDep2);
        content = ((CompoundTerm) content).applySubstitute(substitute);
        TruthValue truth = intersection(taskSentence.truth, belief.truth);
        BudgetValue budget = BudgetFunctions.forward(truth, nal);
        b1 = (nal.doublePremiseTask(content, truth, budget, false, false)) != null;
    }
    substitute.clear();
    {
        Variable varInd1 = new Variable("$varInd1");
        Variable varInd2 = new Variable("$varInd2");
        substitute.put(commonTerm1, varInd1);
        if (commonTerm2 != null) {
            substitute.put(commonTerm2, varInd2);
        }
        Term content = Implication.make(premise1, oldCompound);
        if ((content == null) || (!(content instanceof CompoundTerm))) {
            return false;
        }
        content = ((CompoundTerm) content).applySubstituteToCompound(substitute);
        TruthValue truth;
        if (premise1.equals(taskSentence.term)) {
            truth = induction(belief.truth, taskSentence.truth);
        } else {
            truth = induction(taskSentence.truth, belief.truth);
        }
        BudgetValue budget = BudgetFunctions.forward(truth, nal);
        b2 = nal.doublePremiseTask(content, truth, budget, false, false) != null;
    }
    return b1 || b2;
}
Also used : CompoundTerm(nars.language.CompoundTerm) BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Variable(nars.language.Variable) HashMap(java.util.HashMap) TruthValue(nars.entity.TruthValue) CompoundTerm(nars.language.CompoundTerm) Term(nars.language.Term) Sentence(nars.entity.Sentence)

Example 8 with CompoundTerm

use of nars.language.CompoundTerm in project opennars by opennars.

the class CompositionalRules method decomposeCompound.

/**
 * {<(S|P) ==> M>, <P ==> M>} |- <S ==> M>
 *
 * @param implication The implication term to be decomposed
 * @param componentCommon The part of the implication to be removed
 * @param term1 The other term in the contentInd
 * @param index The location of the shared term: 0 for subject, 1 for
 * predicate
 * @param compoundTask Whether the implication comes from the task
 * @param nal Reference to the memory
 */
private static void decomposeCompound(CompoundTerm compound, Term component, Term term1, int index, boolean compoundTask, int order, DerivationContext nal) {
    if ((compound instanceof Statement) || (compound instanceof ImageExt) || (compound instanceof ImageInt)) {
        return;
    }
    Term term2 = reduceComponents(compound, component, nal.mem());
    if (term2 == null) {
        return;
    }
    long delta = 0;
    while ((term2 instanceof Conjunction) && (((CompoundTerm) term2).term[0] instanceof Interval)) {
        Interval interval = (Interval) ((CompoundTerm) term2).term[0];
        delta += interval.time;
        term2 = ((CompoundTerm) term2).setComponent(0, null, nal.mem());
    }
    Task task = nal.getCurrentTask();
    Sentence sentence = task.sentence;
    Sentence belief = nal.getCurrentBelief();
    Statement oldContent = (Statement) task.getTerm();
    TruthValue v1, v2;
    if (compoundTask) {
        v1 = sentence.truth;
        v2 = belief.truth;
    } else {
        v1 = belief.truth;
        v2 = sentence.truth;
    }
    TruthValue truth = null;
    Term content;
    if (index == 0) {
        content = Statement.make(oldContent, term1, term2, order);
        if (content == null) {
            return;
        }
        if (oldContent instanceof Inheritance) {
            if (compound instanceof IntersectionExt) {
                truth = reduceConjunction(v1, v2);
            } else if (compound instanceof IntersectionInt) {
                truth = reduceDisjunction(v1, v2);
            } else if ((compound instanceof SetInt) && (component instanceof SetInt)) {
                truth = reduceConjunction(v1, v2);
            } else if ((compound instanceof SetExt) && (component instanceof SetExt)) {
                truth = reduceDisjunction(v1, v2);
            } else if (compound instanceof DifferenceExt) {
                if (compound.term[0].equals(component)) {
                    truth = reduceDisjunction(v2, v1);
                } else {
                    truth = reduceConjunctionNeg(v1, v2);
                }
            }
        } else if (oldContent instanceof Implication) {
            if (compound instanceof Conjunction) {
                truth = reduceConjunction(v1, v2);
            } else if (compound instanceof Disjunction) {
                truth = reduceDisjunction(v1, v2);
            }
        }
    } else {
        content = Statement.make(oldContent, term2, term1, order);
        if (content == null) {
            return;
        }
        if (oldContent instanceof Inheritance) {
            if (compound instanceof IntersectionInt) {
                truth = reduceConjunction(v1, v2);
            } else if (compound instanceof IntersectionExt) {
                truth = reduceDisjunction(v1, v2);
            } else if ((compound instanceof SetExt) && (component instanceof SetExt)) {
                truth = reduceConjunction(v1, v2);
            } else if ((compound instanceof SetInt) && (component instanceof SetInt)) {
                truth = reduceDisjunction(v1, v2);
            } else if (compound instanceof DifferenceInt) {
                if (compound.term[1].equals(component)) {
                    truth = reduceDisjunction(v2, v1);
                } else {
                    truth = reduceConjunctionNeg(v1, v2);
                }
            }
        } else if (oldContent instanceof Implication) {
            if (compound instanceof Disjunction) {
                truth = reduceConjunction(v1, v2);
            } else if (compound instanceof Conjunction) {
                truth = reduceDisjunction(v1, v2);
            }
        }
    }
    if (truth != null) {
        BudgetValue budget = BudgetFunctions.compoundForward(truth, content, nal);
        if (delta != 0) {
            long baseTime = task.sentence.getOccurenceTime();
            if (baseTime != Stamp.ETERNAL) {
                baseTime += delta;
                nal.getTheNewStamp().setOccurrenceTime(baseTime);
            }
        }
        // (allow overlap), a form of detachment
        nal.doublePremiseTask(content, truth, budget, false, true);
    }
}
Also used : CompoundTerm(nars.language.CompoundTerm) BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Statement(nars.language.Statement) Inheritance(nars.language.Inheritance) ImageInt(nars.language.ImageInt) SetInt(nars.language.SetInt) CompoundTerm(nars.language.CompoundTerm) Term(nars.language.Term) IntersectionInt(nars.language.IntersectionInt) Implication(nars.language.Implication) DifferenceInt(nars.language.DifferenceInt) Disjunction(nars.language.Disjunction) TruthFunctions.reduceDisjunction(nars.inference.TruthFunctions.reduceDisjunction) IntersectionExt(nars.language.IntersectionExt) TruthValue(nars.entity.TruthValue) TruthFunctions.reduceConjunction(nars.inference.TruthFunctions.reduceConjunction) Conjunction(nars.language.Conjunction) SetExt(nars.language.SetExt) ImageExt(nars.language.ImageExt) DifferenceExt(nars.language.DifferenceExt) Sentence(nars.entity.Sentence) Interval(nars.language.Interval)

Example 9 with CompoundTerm

use of nars.language.CompoundTerm in project opennars by opennars.

the class CompositionalRules method decomposeStatement.

/**
 * {(||, S, P), P} |- S {(&&, S, P), P} |- S
 *
 * @param implication The implication term to be decomposed
 * @param componentCommon The part of the implication to be removed
 * @param compoundTask Whether the implication comes from the task
 * @param nal Reference to the memory
 */
static void decomposeStatement(CompoundTerm compound, Term component, boolean compoundTask, int index, DerivationContext nal) {
    boolean isTemporalConjunction = (compound instanceof Conjunction) && !((Conjunction) compound).isSpatial;
    if (isTemporalConjunction && (compound.getTemporalOrder() == TemporalRules.ORDER_FORWARD) && (index != 0)) {
        return;
    }
    long occurrence_time = nal.getTheNewStamp().getOccurrenceTime();
    if (isTemporalConjunction && (compound.getTemporalOrder() == TemporalRules.ORDER_FORWARD)) {
        if (!nal.getCurrentTask().sentence.isEternal() && compound.term[index + 1] instanceof Interval) {
            long shift_occurrence = ((Interval) compound.term[1]).time;
            occurrence_time = nal.getCurrentTask().sentence.getOccurenceTime() + shift_occurrence;
        }
    }
    Task task = nal.getCurrentTask();
    Sentence taskSentence = task.sentence;
    Sentence belief = nal.getCurrentBelief();
    Term content = reduceComponents(compound, component, nal.mem());
    if (content == null) {
        return;
    }
    TruthValue truth = null;
    BudgetValue budget;
    if (taskSentence.isQuestion() || taskSentence.isQuest()) {
        budget = BudgetFunctions.compoundBackward(content, nal);
        nal.getTheNewStamp().setOccurrenceTime(occurrence_time);
        nal.doublePremiseTask(content, truth, budget, false, false);
        // special inference to answer conjunctive questions with query variables
        if (taskSentence.term.hasVarQuery()) {
            Concept contentConcept = nal.mem().concept(content);
            if (contentConcept == null) {
                return;
            }
            Sentence contentBelief = contentConcept.getBelief(nal, task);
            if (contentBelief == null) {
                return;
            }
            Task contentTask = new Task(contentBelief, task.budget, false);
            nal.setCurrentTask(contentTask);
            Term conj = Conjunction.make(component, content);
            truth = intersection(contentBelief.truth, belief.truth);
            budget = BudgetFunctions.compoundForward(truth, conj, nal);
            nal.getTheNewStamp().setOccurrenceTime(occurrence_time);
            nal.doublePremiseTask(conj, truth, budget, false, false);
        }
    } else {
        TruthValue v1, v2;
        if (compoundTask) {
            v1 = taskSentence.truth;
            v2 = belief.truth;
        } else {
            v1 = belief.truth;
            v2 = taskSentence.truth;
        }
        if (compound instanceof Conjunction) {
            if (taskSentence.isGoal()) {
                if (compoundTask) {
                    truth = intersection(v1, v2);
                } else {
                    return;
                }
            } else {
                // isJudgment
                truth = reduceConjunction(v1, v2);
            }
        } else if (compound instanceof Disjunction) {
            if (taskSentence.isGoal()) {
                if (compoundTask) {
                    truth = reduceConjunction(v2, v1);
                } else {
                    return;
                }
            } else {
                // isJudgment
                truth = reduceDisjunction(v1, v2);
            }
        } else {
            return;
        }
        budget = BudgetFunctions.compoundForward(truth, content, nal);
    }
    nal.getTheNewStamp().setOccurrenceTime(occurrence_time);
    nal.doublePremiseTask(content, truth, budget, false, false);
}
Also used : BudgetValue(nars.entity.BudgetValue) Concept(nars.entity.Concept) Task(nars.entity.Task) Disjunction(nars.language.Disjunction) TruthFunctions.reduceDisjunction(nars.inference.TruthFunctions.reduceDisjunction) TruthValue(nars.entity.TruthValue) TruthFunctions.reduceConjunction(nars.inference.TruthFunctions.reduceConjunction) Conjunction(nars.language.Conjunction) CompoundTerm(nars.language.CompoundTerm) Term(nars.language.Term) Sentence(nars.entity.Sentence) Interval(nars.language.Interval)

Example 10 with CompoundTerm

use of nars.language.CompoundTerm in project opennars by opennars.

the class CompositionalRules method eliminateVariableOfConditionAbductive.

/*
    The other inversion (abduction) should also be studied:
 IN: <<lock1 --> (/,open,$1,_)> ==> <$1 --> key>>.
 IN: <(&&,<#1 --> lock>,<#1 --> (/,open,$2,_)>) ==> <$2 --> key>>.
OUT: <lock1 --> lock>.
    http://code.google.com/p/open-nars/issues/detail?id=40&can=1
    */
public static void eliminateVariableOfConditionAbductive(final int figure, final Sentence sentence, final Sentence belief, final DerivationContext nal) {
    Statement T1 = (Statement) sentence.term;
    Statement T2 = (Statement) belief.term;
    Term S1 = T2.getSubject();
    Term S2 = T1.getSubject();
    Term P1 = T2.getPredicate();
    Term P2 = T1.getPredicate();
    HashMap<Term, Term> res1 = new HashMap<>();
    HashMap<Term, Term> res2 = new HashMap<>();
    HashMap<Term, Term> res3 = new HashMap<>();
    HashMap<Term, Term> res4 = new HashMap<>();
    if (figure == 21) {
        res1.clear();
        res2.clear();
        // this part is
        Variables.findSubstitute(Symbols.VAR_INDEPENDENT, P1, S2, res1, res2);
        // independent, the rule works if it unifies
        T1 = (Statement) T1.applySubstitute(res2);
        if (T1 == null) {
            return;
        }
        T2 = (Statement) T2.applySubstitute(res1);
        if (T2 == null) {
            return;
        }
        S1 = T2.getSubject();
        S2 = T1.getSubject();
        P1 = T2.getPredicate();
        // update the variables because T1 and T2 may have changed
        P2 = T1.getPredicate();
        if (S1 instanceof Conjunction) {
            // try to unify P2 with a component
            for (final Term s1 : ((CompoundTerm) S1).term) {
                res3.clear();
                // here the dependent part matters, see example of Issue40
                res4.clear();
                if (Variables.findSubstitute(Symbols.VAR_DEPENDENT, s1, P2, res3, res4)) {
                    for (Term s2 : ((CompoundTerm) S1).term) {
                        if (!(s2 instanceof CompoundTerm)) {
                            continue;
                        }
                        s2 = ((CompoundTerm) s2).applySubstitute(res3);
                        if (s2 == null || s2.hasVarIndep()) {
                            continue;
                        }
                        if (!s2.equals(s1) && (sentence.truth != null) && (belief.truth != null)) {
                            TruthValue truth = abduction(sentence.truth, belief.truth);
                            BudgetValue budget = BudgetFunctions.compoundForward(truth, s2, nal);
                            nal.doublePremiseTask(s2, truth, budget, false, false);
                        }
                    }
                }
            }
        }
        if (P2 instanceof Conjunction) {
            // try to unify S1 with a component
            for (final Term s1 : ((CompoundTerm) P2).term) {
                res3.clear();
                // here the dependent part matters, see example of Issue40
                res4.clear();
                if (Variables.findSubstitute(Symbols.VAR_DEPENDENT, s1, S1, res3, res4)) {
                    for (Term s2 : ((CompoundTerm) P2).term) {
                        if (!(s2 instanceof CompoundTerm)) {
                            continue;
                        }
                        s2 = ((CompoundTerm) s2).applySubstitute(res3);
                        if (s2 == null || s2.hasVarIndep()) {
                            continue;
                        }
                        if (!s2.equals(s1) && (sentence.truth != null) && (belief.truth != null)) {
                            TruthValue truth = abduction(sentence.truth, belief.truth);
                            BudgetValue budget = BudgetFunctions.compoundForward(truth, s2, nal);
                            nal.doublePremiseTask(s2, truth, budget, false, false);
                        }
                    }
                }
            }
        }
    }
    if (figure == 12) {
        res1.clear();
        res2.clear();
        // this part is
        Variables.findSubstitute(Symbols.VAR_INDEPENDENT, S1, P2, res1, res2);
        // independent, the rule works if it unifies
        T1 = (Statement) T1.applySubstitute(res2);
        if (T1 == null) {
            return;
        }
        T2 = (Statement) T2.applySubstitute(res1);
        if (T2 == null) {
            return;
        }
        S1 = T2.getSubject();
        S2 = T1.getSubject();
        P1 = T2.getPredicate();
        // update the variables because T1 and T2 may have changed
        P2 = T1.getPredicate();
        if (S2 instanceof Conjunction) {
            // try to unify P1 with a component
            for (final Term s1 : ((CompoundTerm) S2).term) {
                res3.clear();
                // here the dependent part matters, see example of Issue40
                res4.clear();
                if (Variables.findSubstitute(Symbols.VAR_DEPENDENT, s1, P1, res3, res4)) {
                    for (Term s2 : ((CompoundTerm) S2).term) {
                        if (!(s2 instanceof CompoundTerm)) {
                            continue;
                        }
                        s2 = ((CompoundTerm) s2).applySubstitute(res3);
                        if (s2 == null || s2.hasVarIndep()) {
                            continue;
                        }
                        if (!s2.equals(s1) && (sentence.truth != null) && (belief.truth != null)) {
                            TruthValue truth = abduction(sentence.truth, belief.truth);
                            BudgetValue budget = BudgetFunctions.compoundForward(truth, s2, nal);
                            nal.doublePremiseTask(s2, truth, budget, false, false);
                        }
                    }
                }
            }
        }
        if (P1 instanceof Conjunction) {
            // try to unify S2 with a component
            for (final Term s1 : ((CompoundTerm) P1).term) {
                res3.clear();
                // here the dependent part matters, see example of Issue40
                res4.clear();
                if (Variables.findSubstitute(Symbols.VAR_DEPENDENT, s1, S2, res3, res4)) {
                    for (Term s2 : ((CompoundTerm) P1).term) {
                        if (!(s2 instanceof CompoundTerm)) {
                            continue;
                        }
                        s2 = ((CompoundTerm) s2).applySubstitute(res3);
                        if (s2 == null || s2.hasVarIndep()) {
                            continue;
                        }
                        if (!s2.equals(s1) && (sentence.truth != null) && (belief.truth != null)) {
                            TruthValue truth = abduction(sentence.truth, belief.truth);
                            BudgetValue budget = BudgetFunctions.compoundForward(truth, s2, nal);
                            nal.doublePremiseTask(s2, truth, budget, false, false);
                        }
                    }
                }
            }
        }
    }
    if (figure == 11) {
        res1.clear();
        res2.clear();
        // this part is
        Variables.findSubstitute(Symbols.VAR_INDEPENDENT, S1, S2, res1, res2);
        // independent, the rule works if it unifies
        T1 = (Statement) T1.applySubstitute(res2);
        if (T1 == null) {
            return;
        }
        T2 = (Statement) T2.applySubstitute(res1);
        if (T2 == null) {
            return;
        }
        S1 = T2.getSubject();
        S2 = T1.getSubject();
        P1 = T2.getPredicate();
        // update the variables because T1 and T2 may have changed
        P2 = T1.getPredicate();
        if (P1 instanceof Conjunction) {
            // try to unify P2 with a component
            for (final Term s1 : ((CompoundTerm) P1).term) {
                res3.clear();
                // here the dependent part matters, see example of Issue40
                res4.clear();
                if (Variables.findSubstitute(Symbols.VAR_DEPENDENT, s1, P2, res3, res4)) {
                    for (Term s2 : ((CompoundTerm) P1).term) {
                        if (!(s2 instanceof CompoundTerm)) {
                            continue;
                        }
                        s2 = ((CompoundTerm) s2).applySubstitute(res3);
                        if (s2 == null || s2.hasVarIndep()) {
                            continue;
                        }
                        if ((!s2.equals(s1)) && (sentence.truth != null) && (belief.truth != null)) {
                            TruthValue truth = abduction(sentence.truth, belief.truth);
                            BudgetValue budget = BudgetFunctions.compoundForward(truth, s2, nal);
                            nal.doublePremiseTask(s2, truth, budget, false, false);
                        }
                    }
                }
            }
        }
        if (P2 instanceof Conjunction) {
            // try to unify P1 with a component
            for (final Term s1 : ((CompoundTerm) P2).term) {
                res3.clear();
                // here the dependent part matters, see example of Issue40
                res4.clear();
                if (Variables.findSubstitute(Symbols.VAR_DEPENDENT, s1, P1, res3, res4)) {
                    for (Term s2 : ((CompoundTerm) P2).term) {
                        if (!(s2 instanceof CompoundTerm)) {
                            continue;
                        }
                        s2 = ((CompoundTerm) s2).applySubstitute(res3);
                        if (s2 == null || s2.hasVarIndep()) {
                            continue;
                        }
                        if (!s2.equals(s1) && (sentence.truth != null) && (belief.truth != null)) {
                            TruthValue truth = abduction(sentence.truth, belief.truth);
                            BudgetValue budget = BudgetFunctions.compoundForward(truth, s2, nal);
                            nal.doublePremiseTask(s2, truth, budget, false, false);
                        }
                    }
                }
            }
        }
    }
    if (figure == 22) {
        res1.clear();
        res2.clear();
        // this part is
        Variables.findSubstitute(Symbols.VAR_INDEPENDENT, P1, P2, res1, res2);
        // independent, the rule works if it unifies
        T1 = (Statement) T1.applySubstitute(res2);
        if (T1 == null) {
            return;
        }
        T2 = (Statement) T2.applySubstitute(res1);
        if (T2 == null) {
            return;
        }
        S1 = T2.getSubject();
        S2 = T1.getSubject();
        P1 = T2.getPredicate();
        // update the variables because T1 and T2 may have changed
        P2 = T1.getPredicate();
        if (S1 instanceof Conjunction) {
            // try to unify S2 with a component
            for (final Term s1 : ((CompoundTerm) S1).term) {
                res3.clear();
                // here the dependent part matters, see example of Issue40
                res4.clear();
                if (Variables.findSubstitute(Symbols.VAR_DEPENDENT, s1, S2, res3, res4)) {
                    for (Term s2 : ((CompoundTerm) S1).term) {
                        if (!(s2 instanceof CompoundTerm)) {
                            continue;
                        }
                        s2 = ((CompoundTerm) s2).applySubstitute(res3);
                        if (s2 == null || s2.hasVarIndep()) {
                            continue;
                        }
                        if (s2 != null && !s2.equals(s1) && (sentence.truth != null) && (belief.truth != null)) {
                            TruthValue truth = abduction(sentence.truth, belief.truth);
                            BudgetValue budget = BudgetFunctions.compoundForward(truth, s2, nal);
                            nal.doublePremiseTask(s2, truth, budget, false, false);
                        }
                    }
                }
            }
        }
        if (S2 instanceof Conjunction) {
            // try to unify S1 with a component
            for (final Term s1 : ((CompoundTerm) S2).term) {
                res3.clear();
                // here the dependent part matters, see example of Issue40
                res4.clear();
                if (Variables.findSubstitute(Symbols.VAR_DEPENDENT, s1, S1, res3, res4)) {
                    for (Term s2 : ((CompoundTerm) S2).term) {
                        if (!(s2 instanceof CompoundTerm)) {
                            continue;
                        }
                        s2 = ((CompoundTerm) s2).applySubstitute(res3);
                        if (s2 == null || s2.hasVarIndep()) {
                            continue;
                        }
                        if (s2 != null && !s2.equals(s1) && (sentence.truth != null) && (belief.truth != null)) {
                            TruthValue truth = abduction(sentence.truth, belief.truth);
                            BudgetValue budget = BudgetFunctions.compoundForward(truth, s2, nal);
                            nal.doublePremiseTask(s2, truth, budget, false, false);
                        }
                    }
                }
            }
        }
    }
}
Also used : CompoundTerm(nars.language.CompoundTerm) BudgetValue(nars.entity.BudgetValue) HashMap(java.util.HashMap) Statement(nars.language.Statement) TruthValue(nars.entity.TruthValue) TruthFunctions.reduceConjunction(nars.inference.TruthFunctions.reduceConjunction) Conjunction(nars.language.Conjunction) CompoundTerm(nars.language.CompoundTerm) Term(nars.language.Term)

Aggregations

CompoundTerm (nars.language.CompoundTerm)46 Term (nars.language.Term)43 TruthValue (nars.entity.TruthValue)30 BudgetValue (nars.entity.BudgetValue)27 Sentence (nars.entity.Sentence)20 Statement (nars.language.Statement)19 Conjunction (nars.language.Conjunction)18 Task (nars.entity.Task)17 Inheritance (nars.language.Inheritance)13 Implication (nars.language.Implication)8 HashMap (java.util.HashMap)7 Variable (nars.language.Variable)7 Interval (nars.language.Interval)6 SetExt (nars.language.SetExt)6 SetInt (nars.language.SetInt)6 Product (nars.language.Product)5 TruthFunctions.reduceConjunction (nars.inference.TruthFunctions.reduceConjunction)4 Equivalence (nars.language.Equivalence)4 ImageExt (nars.language.ImageExt)4 ImageInt (nars.language.ImageInt)4