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

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


      GdlOr or = (GdlOr) literal;
      for(int i = 0; i < or.arity(); i++) {
        getUnsupportedVariablesInLiteral(or.get(i), unsupportedVariables);
      }
    } else if(literal instanceof GdlDistinct) {
      GdlDistinct distinct = (GdlDistinct) literal;
      List<GdlTerm> pair = new ArrayList<GdlTerm>(2); //Easy way to parse functions
      pair.add(distinct.getArg1());
      pair.add(distinct.getArg2());
      getVariablesInBody(pair, unsupportedVariables);
    }
  }
View Full Code Here


            for(Gdl gdl2 : func.getBody())
                processGdl(gdl2, func.getName());
        }
        else if(gdl instanceof GdlDistinct)
        {
            GdlDistinct distinct = (GdlDistinct)gdl;
            processGdl(distinct.getArg1(), null);
            processGdl(distinct.getArg2(), null);
        }
        else if(gdl instanceof GdlNot)
        {
            GdlNot not = (GdlNot)gdl;
            processGdl(not.getBody(), null);
View Full Code Here

            if(literal instanceof GdlNot) {
                GdlNot not = (GdlNot) literal;
                if(not.getBody() instanceof GdlDistinct) {
                    //For now, we can only deal with this if not both are functions.
                    //That means we have to skip that case at this point.
                    GdlDistinct distinct = (GdlDistinct) not.getBody();
                    if(!(distinct.getArg1() instanceof GdlFunction)
                            || !(distinct.getArg2() instanceof GdlFunction))
                        return not;
                }
            }
        }
        return null;
View Full Code Here

        //Figure out the substitution we want...
        //If we have two constants: Either remove one or
        //maybe get rid of the ___?
        //One is a variable: Replace the variable with the other thing
        //throughout the rule
        GdlDistinct distinct = (GdlDistinct) notDistinctLiteral.getBody();
        GdlTerm arg1 = distinct.getArg1();
        GdlTerm arg2 = distinct.getArg2();
        if(arg1 == arg2) {
            //Just remove that literal
            List<GdlLiteral> newBody = new ArrayList<GdlLiteral>();
            newBody.addAll(rule.getBody());
            newBody.remove(notDistinctLiteral);
View Full Code Here

  private static GdlLiteral cleanParentheses(GdlLiteral literal) {
    if(literal instanceof GdlSentence) {
      return cleanParentheses((GdlSentence)literal);
    } else if(literal instanceof GdlDistinct) {
      GdlDistinct distinct = (GdlDistinct) literal;
      GdlTerm term1 = cleanParentheses(distinct.getArg1());
      GdlTerm term2 = cleanParentheses(distinct.getArg2());
      return GdlPool.getDistinct(term1, term2);
    } else if(literal instanceof GdlNot) {
      GdlLiteral body = ((GdlNot) literal).getBody();
      return GdlPool.getNot(cleanParentheses(body));
    } else if(literal instanceof GdlOr) {
View Full Code Here

      //Find all the unsatisfied distincts
      //Find the pair with the earliest var. that needs to be changed
      List<GdlVariable> varsToChange = new ArrayList<GdlVariable>();
      for(int d = 0; d < plan.getDistincts().size(); d++) {
        GdlDistinct distinct = plan.getDistincts().get(d);
        //The assignments must use the assignments implied by nextAssignment
        GdlConstant term1 = replaceVariables(distinct.getArg1());
        GdlConstant term2 = replaceVariables(distinct.getArg2());
        if(term1.equals(term2)) {
          //need to change one of these
          varsToChange.add(plan.getVarsToChangePerDistinct().get(d));
        }
      }
View Full Code Here

      for (GdlTerm term : function.getBody()) {
        newBody.add(replaceVariables(term, assignment));
      }
      return GdlPool.getFunction(name, newBody);
    } else if (gdl instanceof GdlDistinct) {
      GdlDistinct distinct = (GdlDistinct) gdl;
      GdlTerm arg1 = replaceVariables(distinct.getArg1(), assignment);
      GdlTerm arg2 = replaceVariables(distinct.getArg2(), assignment);
      return GdlPool.getDistinct(arg1, arg2);
    } else if (gdl instanceof GdlNot) {
      GdlLiteral internal = ((GdlNot) gdl).getBody();
      return GdlPool.getNot(replaceVariables(internal, assignment));
    } else if (gdl instanceof GdlOr) {
View Full Code Here

      boolean isConstant;

      if (qPrime instanceof GdlDistinct)
      {
        GdlDistinct distinct = (GdlDistinct) qPrime;
        isConstant = askDistinct(distinct, goals, context, theta, cache, renamer, askOne, results, alreadyAsking);
      }
      else if (qPrime instanceof GdlNot)
      {
        GdlNot not = (GdlNot) qPrime;
View Full Code Here

   */
  private Proposition convertConjunct(GdlLiteral literal)
  {
    if ( literal instanceof GdlDistinct )
    {
      GdlDistinct distinct = (GdlDistinct) literal;

      Proposition proposition = new Proposition(GdlPool.getProposition(GdlPool.getConstant("anon")));
      Constant constant = new Constant(!distinct.getArg1().equals(distinct.getArg2()));

      link(constant, proposition);

      components.add(proposition);
      components.add(constant);
View Full Code Here

            }
            return GdlPool.getRule(head, body);
        }
        else if(gdl instanceof GdlDistinct)
        {
            GdlDistinct distinct = (GdlDistinct)gdl;
            GdlTerm arg1 = (GdlTerm)getInstantiationAux(distinct.getArg1(), varInstantiation);
            GdlTerm arg2 = (GdlTerm)getInstantiationAux(distinct.getArg2(), varInstantiation);
            return GdlPool.getDistinct(arg1, arg2);
        }
        else if(gdl instanceof GdlNot)
        {
            GdlNot not = (GdlNot)gdl;
View Full Code Here

TOP

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

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.