setProofStep() public method

public setProofStep ( ProofStep proofStep ) : void
proofStep ProofStep
return void
Esempio n. 1
0
        /**
         * A contrapositive of a chain is a permutation in which a different literal
         * is placed at the front. The contrapositives of a chain are logically
         * equivalent to the original chain.
         *
         * @return a list of contrapositives for this chain.
         */
        public List <Chain> getContrapositives()
        {
            List <Chain>   contrapositives = new List <Chain>();
            List <Literal> lits            = new List <Literal>();

            for (int i = 1; i < literals.Count; i++)
            {
                lits.Clear();
                lits.Add(literals[i]);
                lits.AddRange(literals.Take(i));
                lits.AddRange(literals.GetRange(i + 1, literals.Count));
                Chain cont = new Chain(lits);
                cont.setProofStep(new ProofStepChainContrapositive(cont, this));
                contrapositives.Add(cont);
            }

            return(contrapositives);
        }
Esempio n. 2
0
        public Chain attemptReduction(Chain nearParent, int farParentIndex)
        {
            Chain nnpc = null;

            Literal nearLiteral = nearParent.getHead();

            Dictionary<String, List<Chain>> candidateHeads = null;
            if (nearLiteral.isPositiveLiteral())
            {
                candidateHeads = negHeads;
            }
            else
            {
                candidateHeads = posHeads;
            }

            AtomicSentence nearAtom = nearLiteral.getAtomicSentence();
            String nearestKey = nearAtom.getSymbolicName();
            List<Chain> farParents = candidateHeads[nearestKey];
            if (null != farParents)
            {
                Chain farParent = farParents[farParentIndex];
                standardizeApart(farParent);
                Literal farLiteral = farParent.getHead();
                AtomicSentence farAtom = farLiteral.getAtomicSentence();
                Dictionary<Variable, Term> subst = unifier.unify(nearAtom, farAtom);

                // If I was able to unify with one
                // of the far heads
                if (null != subst)
                {
                    // Want to always apply reduction uniformly
                    Chain topChain = farParent;
                    Literal botLit = nearLiteral;
                    Chain botChain = nearParent;

                    // Need to apply subst to all of the
                    // literals in the reduction
                    List<Literal> reduction = new List<Literal>();
                    foreach (Literal l in topChain.getTail())
                    {
                        AtomicSentence atom = (AtomicSentence)substVisitor.subst(
                                subst, l.getAtomicSentence());
                        reduction.Add(l.newInstance(atom));
                    }
                    reduction.Add(new ReducedLiteral((AtomicSentence)substVisitor
                            .subst(subst, botLit.getAtomicSentence()), botLit
                            .isNegativeLiteral()));
                    foreach (Literal l in botChain.getTail())
                    {
                        AtomicSentence atom = (AtomicSentence)substVisitor.subst(
                                subst, l.getAtomicSentence());
                        reduction.Add(l.newInstance(atom));
                    }

                    nnpc = new Chain(reduction);
                    nnpc.setProofStep(new ProofStepChainReduction(nnpc, nearParent,
                            farParent, subst));
                }
            }

            return nnpc;
        }
Esempio n. 3
0
        // Returns c if no dropping occurred
        private Chain tryDropping(Chain c)
        {
            Literal head = c.getHead();
            if (null != head && (head is ReducedLiteral))
            {
                Chain dropped = new Chain(c.getTail());
                dropped.setProofStep(new ProofStepChainDropped(dropped, c));
                return dropped;
            }

            return c;
        }
Esempio n. 4
0
 // Returns c if no cancellation occurred
 private Chain tryCancellation(Chain c)
 {
     Literal head = c.getHead();
     if (null != head && !(head is ReducedLiteral))
     {
         foreach (Literal l in c.getTail())
         {
             if (l is ReducedLiteral)
             {
                 // if they can be resolved
                 if (head.isNegativeLiteral() != l.isNegativeLiteral())
                 {
                     Dictionary<Variable, Term> subst = unifier.unify(head
                             .getAtomicSentence(), l.getAtomicSentence());
                     if (null != subst)
                     {
                         // I have a cancellation
                         // Need to apply subst to all of the
                         // literals in the cancellation
                         List<Literal> cancLits = new List<Literal>();
                         foreach (Literal lfc in c.getTail())
                         {
                             AtomicSentence a = (AtomicSentence)substVisitor
                                     .subst(subst, lfc.getAtomicSentence());
                             cancLits.Add(lfc.newInstance(a));
                         }
                         Chain cancellation = new Chain(cancLits);
                         cancellation
                                 .setProofStep(new ProofStepChainCancellation(
                                         cancellation, c, subst));
                         return cancellation;
                     }
                 }
             }
         }
     }
     return c;
 }
Esempio n. 5
0
        // END-InferenceProcedure
        //

        //
        // PRIVATE METHODS
        //
        public List<Chain> createChainsFromClauses(List<Clause> clauses)
        {
            List<Chain> chains = new List<Chain>();

            foreach (Clause c in clauses)
            {
                Chain chn = new Chain(c.getLiterals());
                chn.setProofStep(new ProofStepChainFromClause(chn, c));
                chains.Add(chn);
                chains.AddRange(chn.getContrapositives());
            }

            return chains;
        }
Esempio n. 6
0
        public Chain standardizeApart(Chain chain,
                StandardizeApartIndexical standardizeApartIndexical)
        {

            List<Variable> toRename = variableCollector.collectAllVariables(chain);
            Dictionary<Variable, Term> renameSubstitution = new Dictionary<Variable, Term>();

            foreach (Variable var in toRename)
            {
                Variable v = null;
                do
                {
                    v = new Variable(standardizeApartIndexical.getPrefix()
                            + standardizeApartIndexical.getNextIndex());
                    // Ensure the new variable name is not already
                    // accidentally used in the sentence
                } while (toRename.Contains(v));

                renameSubstitution.Add(var, v);
            }

            if (renameSubstitution.Count > 0)
            {
                List<Literal> lits = new List<Literal>();

                foreach (Literal l in chain.getLiterals())
                {
                    AtomicSentence atom = (AtomicSentence)substVisitor.subst(
                            renameSubstitution, l.getAtomicSentence());
                    lits.Add(l.newInstance(atom));
                }

                Chain renamed = new Chain(lits);

                renamed.setProofStep(new ProofStepRenaming(renamed, chain
                        .getProofStep()));

                return renamed;
            }

            return chain;
        }
Esempio n. 7
0
        /**
         * A contrapositive of a chain is a permutation in which a different literal
         * is placed at the front. The contrapositives of a chain are logically
         * equivalent to the original chain.
         * 
         * @return a list of contrapositives for this chain.
         */
        public List<Chain> getContrapositives()
        {
            List<Chain> contrapositives = new List<Chain>();
            List<Literal> lits = new List<Literal>();

            for (int i = 1; i < literals.Count; i++)
            {
                lits.Clear();
                lits.Add(literals[i]);
                lits.AddRange(literals.Take(i));
                lits.AddRange(literals.GetRange(i + 1, literals.Count));
                Chain cont = new Chain(lits);
                cont.setProofStep(new ProofStepChainContrapositive(cont, this));
                contrapositives.Add(cont);
            }

            return contrapositives;
        }