Exemple #1
0
        public AtomicSentence apply(TermEquality assertion,
                                    AtomicSentence expression)
        {
            AtomicSentence altExpression = null;

            IdentifyCandidateMatchingTerm icm = getMatchingSubstitution(assertion
                                                                        .getTerm1(), expression);

            if (null != icm)
            {
                Term replaceWith = substVisitor.subst(
                    icm.getMatchingSubstitution(), assertion.getTerm2());
                // Want to ignore reflexivity axiom situation, i.e. x = x
                if (!icm.getMatchingTerm().Equals(replaceWith))
                {
                    ReplaceMatchingTerm rmt = new ReplaceMatchingTerm();

                    // Only apply demodulation at most once on each call.
                    altExpression = rmt.replace(expression, icm.getMatchingTerm(),
                                                replaceWith);
                }
            }

            return(altExpression);
        }
Exemple #2
0
            public object visitTermEquality(TermEquality equality, object arg)
            {
                Term newTerm1 = (Term)equality.getTerm1().accept(this, arg);
                Term newTerm2 = (Term)equality.getTerm2().accept(this, arg);

                return(new TermEquality(newTerm1, newTerm2));
            }
Exemple #3
0
 public object visitTermEquality(TermEquality equality, object arg)
 {
     equality.getTerm1().accept(this, arg);
     equality.getTerm2().accept(this, arg);
     return(equality);
 }
        public List <Clause> apply(Clause c1, Clause c2, bool standardizeApart)
        {
            List <Clause> paraExpressions = new List <Clause>();

            for (int i = 0; i < 2; i++)
            {
                Clause topClause, equalityClause;
                if (i == 0)
                {
                    topClause      = c1;
                    equalityClause = c2;
                }
                else
                {
                    topClause      = c2;
                    equalityClause = c1;
                }

                foreach (Literal possEqLit in equalityClause.getLiterals())
                {
                    // Must be a positive term equality to be used
                    // for paramodulation.
                    if (possEqLit.isPositiveLiteral() &&
                        possEqLit.getAtomicSentence() is TermEquality)
                    {
                        TermEquality assertion = (TermEquality)possEqLit
                                                 .getAtomicSentence();

                        // Test matching for both sides of the equality
                        for (int x = 0; x < 2; x++)
                        {
                            Term toMatch, toReplaceWith;
                            if (x == 0)
                            {
                                toMatch       = assertion.getTerm1();
                                toReplaceWith = assertion.getTerm2();
                            }
                            else
                            {
                                toMatch       = assertion.getTerm2();
                                toReplaceWith = assertion.getTerm1();
                            }

                            foreach (Literal l1 in topClause.getLiterals())
                            {
                                IdentifyCandidateMatchingTerm icm = getMatchingSubstitution(
                                    toMatch, l1.getAtomicSentence());

                                if (null != icm)
                                {
                                    Term replaceWith = substVisitor.subst(icm
                                                                          .getMatchingSubstitution(),
                                                                          toReplaceWith);

                                    // Want to ignore reflexivity axiom situation,
                                    // i.e. x = x
                                    if (icm.getMatchingTerm().Equals(replaceWith))
                                    {
                                        continue;
                                    }

                                    ReplaceMatchingTerm rmt = new ReplaceMatchingTerm();

                                    AtomicSentence altExpression = rmt.replace(l1
                                                                               .getAtomicSentence(), icm
                                                                               .getMatchingTerm(), replaceWith);

                                    // I have an alternative, create a new clause
                                    // with the alternative and the substitution
                                    // applied to all the literals before returning
                                    List <Literal> newLits = new List <Literal>();
                                    foreach (Literal l2 in topClause.getLiterals())
                                    {
                                        if (l1.Equals(l2))
                                        {
                                            newLits
                                            .Add(l1
                                                 .newInstance((AtomicSentence)substVisitor
                                                              .subst(
                                                                  icm
                                                                  .getMatchingSubstitution(),
                                                                  altExpression)));
                                        }
                                        else
                                        {
                                            newLits
                                            .Add(substVisitor
                                                 .subst(
                                                     icm
                                                     .getMatchingSubstitution(),
                                                     l2));
                                        }
                                    }
                                    // Assign the equality clause literals,
                                    // excluding
                                    // the term equality used.
                                    foreach (Literal l2 in equalityClause.getLiterals())
                                    {
                                        if (possEqLit.Equals(l2))
                                        {
                                            continue;
                                        }
                                        newLits.Add(substVisitor.subst(icm
                                                                       .getMatchingSubstitution(), l2));
                                    }

                                    // Only apply paramodulation at most once
                                    // for each term equality.
                                    Clause nc = null;
                                    if (standardizeApart)
                                    {
                                        sApart.standardizeApart(newLits,
                                                                _emptyLiteralList, _saIndexical);
                                        nc = new Clause(newLits);
                                    }
                                    else
                                    {
                                        nc = new Clause(newLits);
                                    }
                                    nc
                                    .setProofStep(new ProofStepClauseParamodulation(
                                                      nc, topClause, equalityClause,
                                                      assertion));
                                    if (c1.isImmutable())
                                    {
                                        nc.setImmutable();
                                    }
                                    if (!c1.isStandardizedApartCheckRequired())
                                    {
                                        c1.setStandardizedApartCheckNotRequired();
                                    }
                                    paraExpressions.Add(nc);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            return(paraExpressions);
        }