getQuantified() public method

public getQuantified ( ) : Sentence
return Sentence
Example #1
0
        public override Object visitQuantifiedSentence(QuantifiedSentence sentence,
                Object arg) {

                    Dictionary<Variable, Term> substitution = (Dictionary<Variable, Term>)arg;

		Sentence quantified = sentence.getQuantified();
		Sentence quantifiedAfterSubs = (Sentence) quantified.accept(this, arg);

		List<Variable> variables = new List<Variable>();
		foreach (Variable v in sentence.getVariables()) {

			if (substitution.ContainsKey(v)) {
                Term st = substitution[v];
				if (st is Variable) {
					// Only if it is a variable to I replace it, otherwise
					// I drop it.
					variables.Add((Variable) st.copy());
				}
			} else {
				// No substitution for the quantified variable, so
				// keep it.
				variables.Add((Variable)v.copy());
			}
		}

		// If not variables remaining on the quantifier, then drop it
		if (variables.Count == 0) {
			return quantifiedAfterSubs;
		}

		return new QuantifiedSentence(sentence.getQuantifier(), variables,
				quantifiedAfterSubs);
	}
Example #2
0
        public Object visitQuantifiedSentence(QuantifiedSentence sentence,
                Object arg)
        {
            // Ensure I collect quantified variables too
            List<Variable> variables = (List<Variable>)arg;
            variables.AddRange(sentence.getVariables());

            sentence.getQuantified().accept(this, arg);

            return sentence;
        }
        public virtual Object visitQuantifiedSentence(QuantifiedSentence sentence,
                Object arg)
        {
            List<Variable> variables = new List<Variable>();
            foreach (Variable var in sentence.getVariables())
            {
                variables.Add((Variable)var.accept(this, arg));
            }

            return new QuantifiedSentence(sentence.getQuantifier(), variables,
                    (Sentence)sentence.getQuantified().accept(this, arg));
        }
 public Object visitQuantifiedSentence(QuantifiedSentence sentence,
         Object arg)
 {
     sentence.getQuantified().accept(this, arg);
     return arg;
 }
Example #5
0
        public Object visitQuantifiedSentence(QuantifiedSentence sentence,
                Object arg)
        {
            Sentence quantified = sentence.getQuantified();
            List<Variable> universalScope = (List<Variable>)arg;

            // Skolemize: Skolemization is the process of removing existential
            // quantifiers by elimination. This is done by introducing Skolem
            // functions. The general rule is that the arguments of the Skolem
            // function are all the universally quantified variables in whose
            // scope the existential quantifier appears.
            if (Quantifiers.isEXISTS(sentence.getQuantifier()))
            {
                Dictionary<Variable, Term> skolemSubst = new Dictionary<Variable, Term>();
                foreach (Variable eVar in sentence.getVariables())
                {
                    if (universalScope.Count > 0)
                    {
                        // Replace with a Skolem Function
                        String skolemFunctionName = parser.getFOLDomain()
                                .addSkolemFunction();
                        skolemSubst.Add(eVar, new Function(skolemFunctionName,
                                new List<Term>(universalScope)));
                    }
                    else
                    {
                        // Replace with a Skolem Constant
                        String skolemConstantName = parser.getFOLDomain()
                                .addSkolemConstant();
                        skolemSubst.Add(eVar, new Constant(skolemConstantName));
                    }
                }

                Sentence skolemized = substVisitor.subst(skolemSubst, quantified);
                return skolemized.accept(this, arg);
            }

            // Drop universal quantifiers.
            if (Quantifiers.isFORALL(sentence.getQuantifier()))
            {
                // Add to the universal scope so that
                // existential skolemization may be done correctly
                universalScope.AddRange(sentence.getVariables());

                Sentence droppedUniversal = (Sentence)quantified.accept(this, arg);

                // Enusre my scope is removed before moving back up
                // the call stack when returning
                foreach (Variable s in sentence.getVariables())
                {
                    universalScope.Remove(s);
                }
               
                return droppedUniversal;
            }

            // Should not reach here as have already
            // handled the two quantifiers.
            throw new ApplicationException("Unhandled Quantifier:"
                    + sentence.getQuantifier());
        }
Example #6
0
        public Object visitQuantifiedSentence(QuantifiedSentence sentence,
                Object arg)
        {
            List<Variable> seenSoFar = (List<Variable>)arg;

            // Keep track of what I have to subst locally and
            // what my renamed variables will be.
            Dictionary<Variable, Term> localSubst = new Dictionary<Variable, Term>();
            List<Variable> replVariables = new List<Variable>();
            foreach (Variable v in sentence.getVariables())
            {
                // If local variable has be renamed already
                // then I need to come up with own name
                if (seenSoFar.Contains(v))
                {
                    Variable sV = new Variable(quantifiedIndexical.getPrefix()
                            + quantifiedIndexical.getNextIndex());
                    localSubst.Add(v, sV);
                    // Replacement variables should contain new name for variable
                    replVariables.Add(sV);
                }
                else
                {
                    // Not already replaced, this name is good
                    replVariables.Add(v);
                }
            }

            // Apply the local subst
            Sentence subst = substVisitor.subst(localSubst, sentence
                    .getQuantified());

            // Ensure all my existing and replaced variable
            // names are tracked
            seenSoFar.AddRange(replVariables);

            Sentence sQuantified = (Sentence)subst.accept(this, arg);

            return new QuantifiedSentence(sentence.getQuantifier(), replVariables,
                    sQuantified);
        }
Example #7
0
        public Object visitQuantifiedSentence(QuantifiedSentence sentence,
                Object arg)
        {

            return new QuantifiedSentence(sentence.getQuantifier(), sentence
                    .getVariables(), (Sentence)sentence.getQuantified().accept(
                    this, arg));
        }