Package org.ggp.base.util.gdl.grammar

Examples of org.ggp.base.util.gdl.grammar.GdlTerm


    {
      return distinct;
    }
    else
    {
      GdlTerm arg1 = substituteTerm(distinct.getArg1(), theta);
      GdlTerm arg2 = substituteTerm(distinct.getArg2(), theta);

      return GdlPool.getDistinct(arg1, arg2);
    }
  }
View Full Code Here


    {
      return variable;
    }
    else
    {
      GdlTerm result = theta.get(variable);
      GdlTerm betterResult = null;

      while (!(betterResult = substituteTerm(result, theta)).equals(result))
      {
        result = betterResult;
      }
View Full Code Here

    //left body contains variables; right body shouldn't
    if(leftBody.size() != rightBody.size()) {
      return false;
    }
    for(int i = 0; i < leftBody.size(); i++) {
      GdlTerm leftTerm = leftBody.get(i);
      GdlTerm rightTerm = rightBody.get(i);
      if(leftTerm instanceof GdlConstant) {
        if(!leftTerm.equals(rightTerm)) {
          return false;
        }
      } else if(leftTerm instanceof GdlVariable) {
View Full Code Here

        return GdlPool.getConstant(atom.getValue());
  }

  private static GdlDistinct createDistinct(SymbolList list)
  {
    GdlTerm arg1 = createTerm(list.get(1));
    GdlTerm arg2 = createTerm(list.get(2));

    return GdlPool.getDistinct(arg1, arg2);
  }
View Full Code Here

        SentenceForm form = SimpleSentenceForm.create(sentence);
        SentenceFormDomain formWithDomain = domainModel.getDomain(form);

        List<GdlTerm> tuple = GdlUtils.getTupleFromSentence(sentence);
        for (int i = 0; i < tuple.size(); i++) {
          GdlTerm term = tuple.get(i);
          if (term instanceof GdlVariable) {
            GdlVariable var = (GdlVariable) term;
            Set<GdlConstant> domain = formWithDomain.getDomainForSlot(i);
            varDomainsByVar.put(var, domain);
          }
View Full Code Here

            return false;
        }
        for (int i = 0; i < originalBody.size(); i++) {
            ConcurrencyUtils.checkForInterruption();

            GdlTerm originalTerm = originalBody.get(i);
            GdlTerm replacementTerm = replacementBody.get(i);
            if (replacementTerm instanceof GdlVariable) {
                if (!(originalTerm instanceof GdlVariable)) {
                    return false;
                }
            } else if (replacementTerm instanceof GdlFunction) {
View Full Code Here

    }

    for (int i = 0; i < form.getTupleSize(); i++) {
      ConcurrencyUtils.checkForInterruption();

      GdlTerm term = tuple.get(i);
      if (term instanceof GdlConstant) {
        Set<GdlConstant> oldDomainForTerm = oldDomain.get(form).get(i);
        if (oldDomainForTerm.contains(term)) {
          newConstantsByForm.get(form).put(i, (GdlConstant) term);
        }
View Full Code Here

    Set<GdlVariable> multipleVars = new HashSet<GdlVariable>();
    //...which, of course, means we have to spot non-candidate vars
    Set<GdlVariable> nonCandidateVars = new HashSet<GdlVariable>();

    for(int i = 0; i < tuple.size(); i++) {
      GdlTerm term = tuple.get(i);
      if(term instanceof GdlVariable
          && !multipleVars.contains(term)) {
        GdlVariable var = (GdlVariable) term;
        if(candidateVars.contains(var)
            || nonCandidateVars.contains(var)) {
View Full Code Here

    }

    private void addRelToMerge(GdlRelation rel, List<Set<GdlConstant>> merge) {
        for(int i=1; i<rel.arity(); i++)
        {
            GdlTerm t = rel.get(i);
            if(!(t instanceof GdlFunction))
                throw new RuntimeException("Incorrectly constructed base props");

            if(merge.size()<i)
                merge.add(new HashSet<GdlConstant>());
View Full Code Here

            String name = relation.getName().toString();
            if(name.equals("init"))
            {
                if(relation.arity()!=1)
                    throw new RuntimeException("Can't init more than one thing as far as I know.");
                GdlTerm template = relation.get(0);
                if(template instanceof GdlConstant)
                {
                    List<GdlTerm> body = new ArrayList<GdlTerm>();
                    body.add(template);
                    GdlRelation toAdd = GdlPool.getRelation(baseConstant, body);
View Full Code Here

TOP

Related Classes of org.ggp.base.util.gdl.grammar.GdlTerm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.