@Override
 public Result<IBool> is(Name name) {
   if (TreeAdapter.isAppl(getValue())) {
     String consName = TreeAdapter.getConstructorName(getValue());
     if (consName != null) {
       return ResultFactory.bool(Names.name(name).equals(consName), ctx);
     }
   }
   return ResultFactory.bool(false, ctx);
 }
  @Override
  public ITree filterProduction(ITree tree, Object environment) {
    String cons = TreeAdapter.getConstructorName(tree);

    if (cons != null) {
      Environment env = (Environment) environment;
      Result<IValue> var = env.getFrameVariable(cons);

      if (var != null && var instanceof ICallableValue) {
        ICallableValue function = (ICallableValue) var;

        try {
          Result<IValue> result = null;
          if (TreeAdapter.isContextFree(tree)) {
            // For context free trees, try it without layout and literal arguments first.
            result = call(function, TreeAdapter.getASTArgs(tree));
          }

          if (result == null) {
            result = call(function, TreeAdapter.getArgs(tree));
          }

          if (result == null) {
            return tree;
          }

          if (result.getType().isBottom()) {
            return tree;
          }

          if (!(result.getType() instanceof NonTerminalType
              && SymbolAdapter.isEqual(
                  ((NonTerminalType) result.getType()).getSymbol(), TreeAdapter.getType(tree)))) {
            // do not call the function if it does not return the right type
            return tree;
          }

          return (ITree) result.getValue();
        } catch (Filtered f) {
          return null;
        }
      }
    }

    return tree;
  }