Package aterm

Examples of aterm.ATermAppl


    boolean consistent = kb.isConsistent();
    long e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // peform ABox addition which results in a consistent KB
    ATermAppl concept = ATermUtils.makeTermAppl( mindswap + "GraduateStudent" );
    ATermAppl individual = ATermUtils.makeTermAppl( mindswappers + "JohnDoe" );
    kb.addIndividual( individual );
    kb.addType( individual, concept );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = kb.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // peform ABox addition which results in an inconsistent KB
    ATermAppl role = ATermUtils.makeTermAppl( foaf + "mbox" );
    individual = ATermUtils.makeTermAppl( mindswappers + "Christian.Halaschek" );
    ATermAppl mbox = ATermUtils.makeTermAppl( "mailto:kolovski@cs.umd.edu" );
    kb.addPropertyValue( role, individual, mbox );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = kb.isConsistent();
View Full Code Here


    } while (!s.equals(fail));
    return t;
  }

  public void test1(int n) {
    ATermAppl N = tzero;
    for (int i = 0; i < n; i++) {
      N = factory.makeAppl(suc, N);
    }
    ATerm tfib = factory.makeAppl(fib, N);
    normalize(tfib);
View Full Code Here

    // System.out.println("res = fib(4) = " + res);
  }

  public void test3(int n) {
    ATermAppl N = tzero;
    for (int i = 0; i < n; i++) {
      N = factory.makeAppl(suc, N);
    }
    normalizeFib(factory.makeAppl(fib, N));
   
View Full Code Here

   
    System.out.println(factory);
  }

  public ATermAppl normalizePlus(ATermAppl t) {
    ATermAppl res = t;
    while (true) {
      ATermAppl v0 = (ATermAppl) res.getArgument(0);

      // plus(s(s(s(s(s(x))))),y) => plus(x,s(s(s(s(s(y))))))
      if (v0.getAFun() == suc) {
        ATermAppl v1 = (ATermAppl) v0.getArgument(0);
        if (v1.getAFun() == suc) {
          ATermAppl v2 = (ATermAppl) v1.getArgument(0);
          if (v2.getAFun() == suc) {
            ATermAppl v3 = (ATermAppl) v2.getArgument(0);
            if (v3.getAFun() == suc) {
              ATermAppl v4 = (ATermAppl) v3.getArgument(0);
              if (v4.getAFun() == suc) {
                res =
                  factory.makeAppl(
                    plus,
                    v4.getArgument(0),
                    factory.makeAppl(
                      suc,
                      factory.makeAppl(
                        suc,
                        factory.makeAppl(
View Full Code Here

    return res;
  }

  public ATermAppl normalizeFib(ATermAppl t) {

    ATermAppl res = t;
    while (true) {
      // fib(0) = suc(0)
      ATermAppl v0 = (ATermAppl) res.getArgument(0);
      if (v0.getAFun() == zero) {
        res = factory.makeAppl(suc, v0);
        break;
      }
      // fib(suc(0)) => suc(0)
      if (v0.getAFun() == suc) {
        ATermAppl v1 = (ATermAppl) v0.getArgument(0);
        if (v1.getAFun() == zero) {
          res = v0;
          break;
        }
      }
      //  fib(s(s(x))) => plus(fib(x),fib(s(x)))
      //     v0 v1
      if (v0.getAFun() == suc) {
        ATermAppl v1 = (ATermAppl) v0.getArgument(0);
        if (v1.getAFun() == suc) {
          ATermAppl v2 = (ATermAppl) v1.getArgument(0);
          ATermAppl fib1 = normalizeFib(factory.makeAppl(fib, v2));
          ATermAppl fib2 = normalizeFib(factory.makeAppl(fib, v1));
          //System.out.println("adding");
          res = normalizePlus(factory.makeAppl(plus, fib1, fib2));
          break;
        }
      }
View Full Code Here

    }

    if (pattern.getType() == ATerm.PLACEHOLDER) {
      ATerm type = ((ATermPlaceholder) pattern).getPlaceholder();
      if (type.getType() == ATerm.APPL) {
        ATermAppl appl = (ATermAppl) type;
        AFun afun = appl.getAFun();
        if (afun.getName().equals("int") && afun.getArity() == 0 && !afun.isQuoted()) {
          list.add(new Integer(value));
          return true;
        }
      }
View Full Code Here

    return make(fun, i_args, getPureFactory().makeList());
  }

  public boolean equivalent(SharedObject obj){
    if(obj instanceof ATermAppl){
      ATermAppl peer = (ATermAppl) obj;
      if(peer.getType() != getType()) return false;
     
      if(peer.getAFun().equals(fun)){
        for(int i = 0; i < args.length; i++){
          if(!peer.getArgument(i).equals(args[i])){
            return false;
          }
        }
        return peer.getAnnotations().equals(getAnnotations());
      }
    }
    return false;
  }
View Full Code Here

    }

    if (pattern.getType() == ATerm.PLACEHOLDER) {
      ATerm type = ((ATermPlaceholder) pattern).getPlaceholder();
      if (type.getType() == ATerm.APPL) {
        ATermAppl appl = (ATermAppl) type;
        AFun afun = appl.getAFun();
        if (afun.getName().equals("long") && afun.getArity() == 0 && !afun.isQuoted()) {
          list.add(new Long(value));
          return true;
        }
      }
View Full Code Here

      }

      if (l.getFirst().getType() == PLACEHOLDER) {
        ATerm ph_type = ((ATermPlaceholder) l.getFirst()).getPlaceholder();
        if (ph_type.getType() == APPL) {
          ATermAppl appl = (ATermAppl) ph_type;
          if (appl.getName().equals("list")
              && appl.getArguments().isEmpty()) {
            list.add(this);
            return true;
              }
        }
      }
View Full Code Here

  private boolean isListPlaceHolder(ATerm pattern) {
    if (pattern.getType() == ATerm.PLACEHOLDER) {
      ATerm type = ((ATermPlaceholder) pattern).getPlaceholder();
      if (type.getType() == ATerm.APPL) {
        ATermAppl appl = (ATermAppl) type;
        AFun afun = appl.getAFun();
        if (afun.getName().equals("list") && afun.getArity() == 0
            && !afun.isQuoted()) {
          return true;
            }
      }
View Full Code Here

TOP

Related Classes of aterm.ATermAppl

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.