public Clause standardizeApart(Clause clause,
                                       StandardizeApartIndexical standardizeApartIndexical)
        {
            List <Variable>             toRename           = variableCollector.collectAllVariables(clause);
            Dictionary <Variable, Term> renameSubstitution = new Dictionary <Variable, Term>();

            foreach (Variable var in toRename)
            {
                Variable v;
                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[var] = v;
            }

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

                foreach (Literal l in clause.getLiterals())
                {
                    literals.Add(substVisitor.subst(renameSubstitution, l));
                }
                Clause renamed = new Clause(literals);
                renamed.setProofStep(new ProofStepRenaming(renamed, clause
                                                           .getProofStep()));
                return(renamed);
            }
            return(clause);
        }
Exemple #2
0
        public Clause standardizeApart(Clause clause, StandardizeApartIndexical standardizeApartIndexical)
        {
            ISet <Variable>       toRename           = variableCollector.collectAllVariables(clause);
            IMap <Variable, Term> renameSubstitution = CollectionFactory.CreateInsertionOrderedMap <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.Put(var, v);
            }

            if (renameSubstitution.Size() > 0)
            {
                ICollection <Literal> literals = CollectionFactory.CreateQueue <Literal>();

                foreach (Literal l in clause.getLiterals())
                {
                    literals.Add(substVisitor.subst(renameSubstitution, l));
                }
                Clause renamed = new Clause(literals);
                renamed.setProofStep(new ProofStepRenaming(renamed, clause.getProofStep()));
                return(renamed);
            }

            return(clause);
        }
        // Note: see page 327.
        public StandardizeApartResult standardizeApart(Sentence sentence,
                                                       StandardizeApartIndexical standardizeApartIndexical)
        {
            List <Variable>             toRename            = variableCollector.collectAllVariables(sentence);
            Dictionary <Variable, Term> renameSubstitution  = new Dictionary <Variable, Term>();
            Dictionary <Variable, Term> reverseSubstitution = 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);
                reverseSubstitution.Add(v, var);
            }
            Sentence standardized = substVisitor.subst(renameSubstitution,
                                                       sentence);

            return(new StandardizeApartResult(sentence, standardized,
                                              renameSubstitution, reverseSubstitution));
        }
        // Note: see page 327.
        public StandardizeApartResult standardizeApart(Sentence aSentence,
                StandardizeApartIndexical standardizeApartIndexical)
        {
            List<Variable> toRename = variableCollector
                    .collectAllVariables(aSentence);
            Dictionary<Variable, Term> renameSubstitution = new Dictionary<Variable, Term>();
            Dictionary<Variable, Term> reverseSubstitution = 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);
                reverseSubstitution.Add(v, var);
            }

            Sentence standardized = substVisitor.subst(renameSubstitution,
                    aSentence);

            return new StandardizeApartResult(aSentence, standardized,
                    renameSubstitution, reverseSubstitution);
        }
Exemple #5
0
        public Dictionary <Variable, Term> standardizeApart(List <Literal> l1Literals,
                                                            List <Literal> l2Literals,
                                                            StandardizeApartIndexical standardizeApartIndexical)
        {
            List <Variable> toRename = new List <Variable>();

            foreach (Literal pl in l1Literals)
            {
                toRename.AddRange(variableCollector.collectAllVariables(pl
                                                                        .getAtomicSentence()));
            }
            foreach (Literal nl in l2Literals)
            {
                toRename.AddRange(variableCollector.collectAllVariables(nl
                                                                        .getAtomicSentence()));
            }

            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));
                if (renameSubstitution.ContainsKey(var))
                {
                    renameSubstitution[var] = v;
                }
                else
                {
                    renameSubstitution.Add(var, v);
                }
            }

            List <Literal> posLits = new List <Literal>();
            List <Literal> negLits = new List <Literal>();

            foreach (Literal pl in l1Literals)
            {
                posLits.Add(substVisitor.subst(renameSubstitution, pl));
            }
            foreach (Literal nl in l2Literals)
            {
                negLits.Add(substVisitor.subst(renameSubstitution, nl));
            }

            l1Literals.Clear();
            l1Literals.AddRange(posLits);
            l2Literals.Clear();
            l2Literals.AddRange(negLits);

            return(renameSubstitution);
        }
Exemple #6
0
        public IMap <Variable, Term> standardizeApart(ICollection <Literal> l1Literals,
                                                      ICollection <Literal> l2Literals,
                                                      StandardizeApartIndexical standardizeApartIndexical)
        {
            ISet <Variable> toRename = CollectionFactory.CreateSet <Variable>();

            foreach (Literal pl in l1Literals)
            {
                toRename.AddAll(variableCollector.collectAllVariables(pl
                                                                      .getAtomicSentence()));
            }
            foreach (Literal nl in l2Literals)
            {
                toRename.AddAll(variableCollector.collectAllVariables(nl.getAtomicSentence()));
            }

            IMap <Variable, Term> renameSubstitution = CollectionFactory.CreateInsertionOrderedMap <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.Put(var, v);
            }

            ICollection <Literal> posLits = CollectionFactory.CreateQueue <Literal>();
            ICollection <Literal> negLits = CollectionFactory.CreateQueue <Literal>();

            foreach (Literal pl in l1Literals)
            {
                posLits.Add(substVisitor.subst(renameSubstitution, pl));
            }
            foreach (Literal nl in l2Literals)
            {
                negLits.Add(substVisitor.subst(renameSubstitution, nl));
            }

            l1Literals.Clear();
            l1Literals.AddAll(posLits);
            l2Literals.Clear();
            l2Literals.AddAll(negLits);

            return(renameSubstitution);
        }
        public Clause standardizeApart(Clause clause,
                StandardizeApartIndexical standardizeApartIndexical)
        {

            List<Variable> toRename = variableCollector.collectAllVariables(clause);
            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));

                if (renameSubstitution.ContainsKey(var))
                {
                    renameSubstitution[var] = v;
                }
                else
                {
                    renameSubstitution.Add(var, v);
                }
            }

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

                foreach (Literal l in clause.getLiterals())
                {
                    literals.Add(substVisitor.subst(renameSubstitution, l));
                }
                Clause renamed = new Clause(literals);
                renamed.setProofStep(new ProofStepRenaming(renamed, clause
                        .getProofStep()));
                return renamed;
            }

            return clause;
        }
Exemple #8
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);
        }
        public Dictionary<Variable, Term> standardizeApart(List<Literal> l1Literals,
                List<Literal> l2Literals,
                StandardizeApartIndexical standardizeApartIndexical)
        {
            List<Variable> toRename = new List<Variable>();

            foreach (Literal pl in l1Literals)
            {
                toRename.AddRange(variableCollector.collectAllVariables(pl
                        .getAtomicSentence()));
            }
            foreach (Literal nl in l2Literals)
            {
                toRename.AddRange(variableCollector.collectAllVariables(nl
                        .getAtomicSentence()));
            }

            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));
                if (renameSubstitution.ContainsKey(var))
                {
                    renameSubstitution[var] = v;
                }
                else
                {
                    renameSubstitution.Add(var, v);
                }
            }

            List<Literal> posLits = new List<Literal>();
            List<Literal> negLits = new List<Literal>();

            foreach (Literal pl in l1Literals)
            {
                posLits.Add(substVisitor.subst(renameSubstitution, pl));
            }
            foreach (Literal nl in l2Literals)
            {
                negLits.Add(substVisitor.subst(renameSubstitution, nl));
            }

            l1Literals.Clear();
            l1Literals.AddRange(posLits);
            l2Literals.Clear();
            l2Literals.AddRange(negLits);

            return renameSubstitution;
        }
        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;
        }