Package aterm

Examples of aterm.ATerm


     */
    public String unfoldTerm(RDFNode clazz) throws NotUnfoldableException,MatchingException {
        if ( getKB().getTBox().Tu==null) {
            getKB().getTBox().split();           
          }
        ATerm term = node2term(clazz);
        if (term==null) {
            ErrorLog.instanceOf().report("Can't find Term for class " + clazz.toString());
            throw new MatchingException("Can't find Term for class " + clazz.toString());           
        }
        String result =( (ATerm) getKB().getTBox().Tu.unfoldTerm((ATermAppl) term) ).toString();
View Full Code Here


    ruleNumber++;

    // fib(suc(suc(X))) -> plus(fib(X),fib(suc(X)))
    list = subject.match(lhs[ruleNumber]);
    if (list != null) {
      ATerm X = (ATerm) list.get(0);
      list.add(X);
      return factory.make(rhs[ruleNumber], list);
    }
    ruleNumber++;

    // plus(zero,X) -> X
    list = subject.match(lhs[ruleNumber]);
    if (list != null) {
      return factory.make(rhs[ruleNumber], list);
    }
    ruleNumber++;

    // plus(suc(X),Y) -> plus(X,suc(Y))
    list = subject.match(lhs[ruleNumber]);
    if (list != null) {
      return factory.make(rhs[ruleNumber], list);
    }
    ruleNumber++;

    // congruence (suc)
    list = subject.match(lhs[ruleNumber]);
    if (list != null) {
      //System.out.println("congsuc"); // applied 1184122 times fir fib(14)
      ATerm X = (ATerm) list.get(0);
      ATerm Xp = oneStep(X);
      if (Xp.equals(fail)) {
        return fail;
      }
            list.clear();
            list.add(Xp);
            return factory.make(rhs[ruleNumber], list);
    }
    ruleNumber++;

    // congruence (plus)
    list = subject.match(lhs[ruleNumber]);
    if (list != null) {
      //System.out.println("congplus"); // applied 9159 times fir fib(14)
      ATerm X = (ATerm) list.get(0);
      ATerm Xp = oneStep(X);
      if (Xp.equals(fail)) {
        ATerm Y = (ATerm) list.get(1);
        ATerm Yp = oneStep(Y);
        if (Yp.equals(fail)) {
          return fail;
        }
                list.clear();
                list.add(X);
                list.add(Yp);
                return factory.make(rhs[ruleNumber], list);
      }
            ATerm Y = (ATerm) list.get(1);
            list.clear();
            list.add(Xp);
            list.add(Y);
            return factory.make(rhs[ruleNumber], list);
    }
View Full Code Here

    }

    // fib(suc(suc(X))) -> plus(fib(X),fib(suc(X)))
    list = subject.match(lhs[2]);
    if (list != null) {
      ATerm X = (ATerm) list.get(0);
      ATerm X1 = normalize(factory.makeAppl(fib, X));
      ATerm X2 = normalize(factory.makeAppl(fib, factory.makeAppl(suc, X)));
      return factory.makeAppl(plus, X1, X2);
    }

    // plus(zero,X) -> X
    list = subject.match(lhs[3]);
View Full Code Here

    return fail;
  }

  public ATerm normalize(ATerm t) {
    ATerm s = t;
    do {
      t = s;
      s = oneStep(t);
    } while (!s.equals(fail));
    return t;
  }
View Full Code Here

  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

            int depth = 5;
            int fanout = 5;

            long beforeBuild = System.currentTimeMillis();
            fun = factory.makeAFun("f", fanout, false);
            ATerm term = buildTerm(depth, fanout);
            long beforeVisit = System.currentTimeMillis();
            NodeCounter nodeCounter = new NodeCounter();
            jjtraveler.Visitor topDownNodeCounter = new jjtraveler.TopDown(
                    nodeCounter);
            try {
View Full Code Here

    private static ATerm buildTerm(int depth, int fanout) {
        if (depth == 1) {
            return factory.makeInt(id++);
        }
        ATerm[] args = new ATerm[fanout];
        ATerm arg = buildTerm(depth - 1, fanout);
        for (int i = 0; i < fanout; i++) {
            args[i] = arg;
        }
        return factory.makeAppl(fun, args);
    }
View Full Code Here

      throw new RuntimeException("assertion failed.");
    }
  }

  void testReadText() throws FileNotFoundException, IOException {
    ATerm t = factory.readFromTextFile(new FileInputStream(srcdir + "/" + "test.trm"));
    baseline = t;
  }
View Full Code Here

    ATerm t = factory.readFromTextFile(new FileInputStream(srcdir + "/" + "test.trm"));
    baseline = t;
  }
 
  void testReadBAF() throws FileNotFoundException, IOException {
    ATerm t = factory.readFromBinaryFile(new FileInputStream(srcdir + "/" + "test.baf"));
    test_assert(t.equals(baseline));
  }
View Full Code Here

  void testReadSAF() {
    // test SAF reader
  }
 
  void testReadTAF() throws FileNotFoundException, IOException {
    ATerm t = factory.readFromSharedTextFile(new FileInputStream(srcdir + "/" + "test.taf"));
    test_assert(t.equals(baseline));
  }
View Full Code Here

TOP

Related Classes of aterm.ATerm

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.