示例#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);
        }
        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);
        }
示例#3
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;
        }
示例#4
0
        public ISet <Clause> Apply(Clause c1, Clause c2, bool standardizeApart)
        {
            ISet <Clause> paraExpressions = new HashedSet <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.AtomicSentence is TermEquality)
                    {
                        var assertion = (TermEquality)possEqLit.AtomicSentence;

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

                            foreach (Literal l1 in topClause.GetLiterals())
                            {
                                var icm = GetMatchingSubstitution(
                                    toMatch, l1.AtomicSentence);

                                if (icm != null)
                                {
                                    ITerm replaceWith = substVisitor.Subst(
                                        icm.GetMatchingSubstitution(), toReplaceWith);

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

                                    var rmt = new ReplaceMatchingTerm();

                                    IAtomicSentence altExpression = rmt.Replace(l1.AtomicSentence,
                                                                                icm.GetMatchingTerm(), replaceWith);

                                    // I have an alternative, create a new clause
                                    // with the alternative and the substitution
                                    // applied to all the literals before returning
                                    var newLits = new List <Literal>();
                                    foreach (Literal l2 in topClause.GetLiterals())
                                    {
                                        if (l1.Equals(l2))
                                        {
                                            newLits.Add(l1.NewInstance((IAtomicSentence)substVisitor
                                                                       .Subst(icm.GetMatchingSubstitution(), altExpression)));
                                        }
                                        else
                                        {
                                            newLits.Add(substVisitor.Subst(icm.GetMatchingSubstitution(), l2));
                                        }
                                    }
                                    // Assign the equality clause literals,
                                    // excluding
                                    // the term equality used.
                                    newLits.AddRange(from l2 in equalityClause.GetLiterals()
                                                     where !possEqLit.Equals(l2)
                                                     select this.substVisitor.Subst(icm.GetMatchingSubstitution(), l2));

                                    // Only apply paramodulation at most once
                                    // for each term equality.
                                    Clause nc;
                                    if (standardizeApart)
                                    {
                                        sApart.GetStandardizeApartResult(newLits, _emptyLiteralList, _saIndexical);
                                        nc = new Clause(newLits);
                                    }
                                    else
                                    {
                                        nc = new Clause(newLits);
                                    }
                                    nc.SetProofStep(new ProofStepClauseParamodulation(nc, topClause, equalityClause, assertion));
                                    if (c1.Immutable)
                                    {
                                        nc.Immutable = true;
                                    }
                                    if (!c1.IsStandardizedApartCheckRequired())
                                    {
                                        c1.SetStandardizedApartCheckNotRequired();
                                    }
                                    paraExpressions.Add(nc);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            return(paraExpressions);
        }
示例#5
0
        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;
        }