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

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


                        {
                            for(Gdl replacement : expandedList)
                            {
                                List<GdlLiteral> newRhs = new ArrayList<GdlLiteral>(rhs);
                                if(!(replacement instanceof GdlLiteral)) throw new RuntimeException("Top level return value is different type of gdl.");
                                GdlLiteral newLit = (GdlLiteral)replacement;
                                newRhs.set(i, newLit);
                                rval.add(newRhs);
                            }
                            expandedSomething = true;
                            break;
View Full Code Here


            expandedChild = expandFirstOr(not.getBody());
            rval = new ArrayList<Gdl>();
            for(Gdl g : expandedChild)
            {
                if(!(g instanceof GdlLiteral)) throw new RuntimeException("Not must have literal child.");
                GdlLiteral lit = (GdlLiteral)g;
                rval.add(GdlPool.getNot(lit));
            }
            return rval;
        }
        else if(gdl instanceof GdlOr)
View Full Code Here

        Set<GdlRule> rules = model.getRules(nextForm);
        if(rules.size() == 1) {
          GdlRule rule = rules.iterator().next();
          //Persistence rule: Exactly one literal, the "true" form of the sentence
          if(rule.arity() == 1) {
            GdlLiteral literal = rule.get(0);
            if(literal instanceof GdlRelation) {
              //Check that it really is the true form
              SentenceForm trueForm = nextForm.withName(GdlPool.getConstant("true"));
              if(trueForm.matches((GdlRelation) literal)) {
                GdlSentence head = rule.getHead();
View Full Code Here

        {
            results.add(Substituter.substitute(template, theta));
        }
        else
        {
            GdlLiteral literal = template.getBody().get(index);
            if ( literal instanceof GdlSentence )
            {
                GdlSentence sentence = (GdlSentence) Substituter.substitute(literal, theta);
                for ( GdlRule instantiation : getInstantiations(sentence.getName()) )
                {
View Full Code Here

            return GdlPool.getDistinct(arg1, arg2);
        }
        else if(gdl instanceof GdlNot)
        {
            GdlNot not = (GdlNot)gdl;
            GdlLiteral body = (GdlLiteral)getInstantiationAux(not.getBody(), varInstantiation);
            return GdlPool.getNot(body);
        }
        else if(gdl instanceof GdlOr)
        {
            GdlOr or = (GdlOr)gdl;
            List<GdlLiteral> body = new ArrayList<GdlLiteral>();
            for(int i=0; i<or.arity(); i++)
            {
                body.add((GdlLiteral)getInstantiationAux(or.get(i), varInstantiation));
            }
            return GdlPool.getOr(body);
        }
        else if(gdl instanceof GdlProposition)
        {
            return gdl;
        }
        else if(gdl instanceof GdlConstant)
        {
            return gdl;
        }
        else if(gdl instanceof GdlFunction)
        {
            GdlFunction func = (GdlFunction)gdl;
            List<GdlTerm> body = new ArrayList<GdlTerm>();
            for(int i=0; i<func.arity(); i++)
            {
                body.add((GdlTerm)getInstantiationAux(func.get(i), varInstantiation));
            }
            return GdlPool.getFunction(func.getName(), body);
        }
        else if(gdl instanceof GdlVariable)
        {
View Full Code Here

                        {
                            for(Gdl replacement : expandedList)
                            {
                                List<GdlLiteral> newRhs = new ArrayList<GdlLiteral>(rhs);
                                if(!(replacement instanceof GdlLiteral)) throw new RuntimeException("Top level return value is different type of gdl.");
                                GdlLiteral newLit = (GdlLiteral)replacement;
                                newRhs.set(i, newLit);
                                rval.add(newRhs);
                            }
                            expandedSomething = true;
                            break;
View Full Code Here

            expandedChild = expandFirstOr(not.getBody());
            rval = new ArrayList<Gdl>();
            for(Gdl g : expandedChild)
            {
                if(!(g instanceof GdlLiteral)) throw new RuntimeException("Not must have literal child.");
                GdlLiteral lit = (GdlLiteral)g;
                rval.add(GdlPool.getNot(lit));
            }
            return rval;
        }
        else if(gdl instanceof GdlOr)
View Full Code Here

    {
      return not;
    }
    else
    {
      GdlLiteral body = renameLiteral(not.getBody(), renamings);
      return GdlPool.getNot(body);
    }
  }
View Full Code Here

TOP

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

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.