Package aterm

Examples of aterm.ATermList


      System.exit(1);
    }
  }

  private ATerm buildDictionary(ADT adt) {
    ATermList afun_list = makeAFunList();
    ATermList term_list = factory.makeList();

    return factory.make("[afuns(<term>),terms(<term>)]", afun_list,
        term_list);
  }
View Full Code Here


    return factory.make("[afuns(<term>),terms(<term>)]", afun_list,
        term_list);
  }

  private ATermList makeAFunList() {
    ATermList afun_list = factory.makeList();
    Iterator<AFun> afuns = afunRegister.aFunIterator();

    while (afuns.hasNext()) {
      AFun afun = afuns.next();
      ATerm entry = makeDictEntry(afun);
      afun_list = afun_list.insert(entry);
    }
    return afun_list;
  }
View Full Code Here

    }

    private void extractFields(ATerm t, Location loc) {
        AFun fun;
        ATermAppl appl;
        ATermList list;

        switch (t.getType()) {
            case ATerm.APPL :
                //{{{ Call 'extractFields' for every argument

                appl = (ATermAppl) t;
                fun = appl.getAFun();
                for (int i = 0; i < fun.getArity(); i++) {
                    Location newloc = (Location) loc.clone();
                    newloc.addStep(new Step(Step.ARG, i));
                    extractFields(appl.getArgument(i), newloc);
                }

                //}}}
                break;

            case ATerm.LIST :
                //{{{ Call 'extractFields' for every element

                list = (ATermList) t;
                for (int i = 0; !list.isEmpty(); i++) {
                    Location newloc = (Location) loc.clone();
                    newloc.addStep(new Step(Step.ELEM, i));
                    extractFields(list.getFirst(), newloc);
                    list = list.getNext();
                }

                //}}}
                break;

            case ATerm.PLACEHOLDER :
                //{{{ Add a new field based on this placeholder

                ATerm ph = ((ATermPlaceholder) t).getPlaceholder();

                if (ph.getType() == ATerm.LIST) {
                    list = (ATermList) ph;
                    appl = (ATermAppl) list.elementAt(0);
                    String fieldId = appl.getAFun().getName();
                    appl = (ATermAppl) appl.getArgument(0);
                    String fieldType = appl.getAFun().getName();
                    loc.makeTail();
                    addField(fieldId, fieldType, loc);
View Full Code Here

  public static boolean containsPlaceholder(ATerm term) {
    switch (term.getType()) {
    case ATerm.PLACEHOLDER:
      return true;
    case ATerm.LIST: {
      ATermList list = (ATermList) term;
      if (list.isEmpty()) {
        return false;
      }
      return containsPlaceholder(list.getFirst())
          || containsPlaceholder(list.getNext());
    }
    case ATerm.APPL: {
      ATermAppl appl = (ATermAppl) term;
      int arity = appl.getArity();
      for (int i = 0; i < arity; i++) {
View Full Code Here

      for (int i = 0; i < fun.getArity(); i++) {
        newargs[i] = buildMatchPattern(appl.getArgument(i));
      }
      return pattern.getFactory().makeAppl(fun, newargs);
    case ATerm.LIST:
      ATermList list = (ATermList) t;
      ATerm[] elems = new ATerm[list.getLength()];
      int i = 0;
      while (!list.isEmpty()) {
        elems[i++] = buildMatchPattern(list.getFirst());
        list = list.getNext();
      }
      for (i = elems.length - 1; i >= 0; i--) {
        list = list.insert(elems[i]);
      }
      return list;
    case ATerm.PLACEHOLDER:
      ATerm ph = ((ATermPlaceholder) t).getPlaceholder();
      if (ph.getType() == ATerm.LIST) {
View Full Code Here

    return getId().equals(ListType.EMPTY_LIST_ALT_NAME) && (subst != null);
  }

  public boolean isMany() {
    if (getPattern().getType() == ATerm.LIST) {
      ATermList l = (ATermList) getPattern();
      ATerm headPh = l.getFirst();
      ATerm tailList = l.getNext();

      if (headPh != null && headPh.getType() == ATerm.PLACEHOLDER
          && tailList.getType() == ATerm.LIST) {
        ATerm head = ((ATermPlaceholder) headPh).getPlaceholder();
        ATerm tailPh = ((ATermList) tailList).getFirst();
View Full Code Here

    return false;
  }

  public boolean isSingle() {
    if (getPattern().getType() == ATerm.LIST) {
      ATermList l = (ATermList) getPattern();
      ATerm headPh = l.getFirst();
      ATerm tailList = l.getNext();

      if (headPh != null && headPh.getType() == ATerm.PLACEHOLDER
          && tailList.getType() == ATerm.LIST) {
        ATerm head = ((ATermPlaceholder) headPh).getPlaceholder();
        ATermList tail = ((ATermList) tailList);
        if (tail.isEmpty()) {
          ATerm headPattern = getPattern().getFactory().parse(
              "head(<term>)");
          List<Object> subst1 = head.match(headPattern);
          if (getId().equals(ListType.SINGLE_LIST_ALT_NAME)
              && (subst1 != null)) {
View Full Code Here

   * @param disjunction
   */
  protected void applyDisjunctionRule(Individual node, ATermAppl disjunction) {
    // disjunction is now in the form not(and([not(d1), not(d2), ...]))
    ATermAppl a = (ATermAppl) disjunction.getArgument( 0 );
    ATermList disjuncts = (ATermList) a.getArgument( 0 );
    ATermAppl[] disj = new ATermAppl[disjuncts.getLength()];

    for( int index = 0; !disjuncts.isEmpty(); disjuncts = disjuncts.getNext(), index++ ) {
      disj[index] = ATermUtils.negate( (ATermAppl) disjuncts.getFirst() );
      if( node.hasType( disj[index] ) )
        return;
    }

    DisjunctionBranch newBranch = new DisjunctionBranch( strategy.getABox(), strategy, node,
View Full Code Here

    private ATermAppl canonicalize(ATermAppl term) {
    if( ATermUtils.isAnd( term ) || ATermUtils.isOr( term ) ) {
      List<ATermAppl> list = new ArrayList<ATermAppl>();
      for( ATermList l = (ATermList) term.getArgument( 0 ); !l.isEmpty(); l = l.getNext() )
        list.add( canonicalize( (ATermAppl) l.getFirst() ) );
      ATermList args = ATermUtils.toSet( list );
      if( ATermUtils.isAnd( term ) )
        return ATermUtils.makeAnd( args );
      else
        return ATermUtils.makeOr( args );
    }
View Full Code Here

      assertEquals( expectedTypes, actualTypes );

      kb.addSubClass( A, ATermUtils.makeNot( B ) );
      assertFalse( kb.isConsistent() );

      ATermList list = ATermUtils.toSet( new ATerm[] { A, B, D }, 3 );
      kb.addDisjointClasses( list );
      assertFalse( kb.isConsistent() );

      assertTrue( kb.removeAxiom( ATermUtils.makeDisjoints( list ) ) );
      assertFalse( kb.isConsistent() );
View Full Code Here

TOP

Related Classes of aterm.ATermList

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.