// private methods - each method represents the invocation of a single rule
  // for a certain query
  // query: isFrequentCustomer
  // rule: rule1: (c.getTransactionCount())>5 -> FrequentCustomer(c);
  private static ResourceIterator<FrequentCustomerRel> isFrequentCustomer_0(
      final DerivationController _derivation, final Customer customer) {

    _derivation.log(
        "test.org.mandarax.compiler.reldef7.FrequentCustomer.rule1",
        DerivationController.RULE,
        _annotations_rule1);

    // utility class used to keep track of variables bindings
    // rule: rule1: (c.getTransactionCount())>5 -> FrequentCustomer(c);
    // prereqs: [(c.getTransactionCount())>5]
    class _Bindings {
      private test.org.mandarax.compiler.Customer c = customer;
    }
    final _Bindings _bindings = new _Bindings();
    ResourceIterator<?> _tmp = null;

    // apply prerequisite (c.getTransactionCount())>5

    // case 4
    if (!((_bindings.c.getTransactionCount()) > 5)) {
      return EmptyIterator.DEFAULT;
    }

    // rule head

    return new SingletonIterator(new FrequentCustomerRel(_bindings.c));
  }
  static ResourceIterator<SemiOrphanRel> isSemiOrphan(
      final DerivationController _derivation, final Person person) {
    final int _derivationlevel = _derivation.size();
    return new IteratorChain<SemiOrphanRel>(2) {

      public ResourceIterator<SemiOrphanRel> getNextIterator(int pos) {
        switch (pos) {
          case 0:
            {
              // invoke rule1: isYoung(p) & Father(f,p) & not Mother(m,p)
              // -> SemiOrphan(p);
              return isSemiOrphan_0(_derivation.pop(_derivationlevel), person);
            }

          case 1:
            {
              // invoke rule2: isYoung(p) & not Father(f,p) & Mother(m,p)
              // -> SemiOrphan(p);
              return isSemiOrphan_1(_derivation.pop(_derivationlevel), person);
            }

          default:
            return EmptyIterator.DEFAULT;
        }
      }
    };
  }
  static ResourceIterator<FrequentCustomerRel> isFrequentCustomer(
      final DerivationController _derivation, final Customer customer) {
    final int _derivationlevel = _derivation.size();
    return new IteratorChain<FrequentCustomerRel>(2) {

      public ResourceIterator<FrequentCustomerRel> getNextIterator(int pos) {
        switch (pos) {
          case 0:
            {
              // invoke rule1: (c.getTransactionCount())>5 ->
              // FrequentCustomer(c);
              return isFrequentCustomer_0(_derivation.pop(_derivationlevel), customer);
            }

          case 1:
            {
              // invoke rule2: (c.getTransactionCount())>3 &
              // (c.getTurnover())>500 -> FrequentCustomer(c);
              return isFrequentCustomer_1(_derivation.pop(_derivationlevel), customer);
            }

          default:
            return EmptyIterator.DEFAULT;
        }
      }
    };
  }
  // private methods - each method represents the invocation of a single rule
  // for a certain query
  // query: isSemiOrphan
  // rule: rule1: isYoung(p) & Father(f,p) & not Mother(m,p) -> SemiOrphan(p);
  private static ResourceIterator<SemiOrphanRel> isSemiOrphan_0(
      final DerivationController _derivation, final Person person) {

    _derivation.log(
        "test.org.mandarax.compiler.naf1.SemiOrphan.rule1",
        DerivationController.RULE,
        _annotations_rule1);

    // utility class used to keep track of variables bindings
    // rule: rule1: isYoung(p) & Father(f,p) & not Mother(m,p) ->
    // SemiOrphan(p);
    // prereqs: [isYoung(p), Father(f,p), not Mother(m,p)]
    class _Bindings {
      private test.org.mandarax.compiler.Person p = person;
      private test.org.mandarax.compiler.Person f = null;
      private test.org.mandarax.compiler.Person m = null;
    }
    final _Bindings _bindings = new _Bindings();
    ResourceIterator<?> _tmp = null;

    // apply prerequisite isYoung(p)

    // case 4

    _tmp = isYoungRelInstances.isYoung(_derivation.push(), _bindings.p);

    if (!_tmp.hasNext()) {
      _tmp.close();
      return EmptyIterator.DEFAULT;
    }

    // apply prerequisite Father(f,p)

    // case 1
    final ResourceIterator<FatherRel> _iterator2 =
        FatherRelInstances.getFather(_derivation.push(), _bindings.p);

    // apply prerequisite not Mother(m,p)

    // case 3

    com.google.common.base.Predicate<FatherRel> _filter3 =
        new com.google.common.base.Predicate<FatherRel>() {
          public boolean apply(FatherRel _object) {
            // bind parameters from Father(f,p)
            _bindings.f = _object.father;

            ResourceIterator<MotherRel> _r =
                MotherRelInstances.getMother(_derivation.push(), _bindings.p);
            boolean _b = _r.hasNext();
            _r.close();
            return !_b;
          }
        };
    final ResourceIterator<FatherRel> _iterator3 =
        new FilteredIterator<FatherRel>(_iterator2, _filter3);

    // rule head

    return new NestedIterator<FatherRel, SemiOrphanRel>(_iterator3) {
      public ResourceIterator<SemiOrphanRel> getNextIterator(FatherRel _object) {
        // bind parameters from Father(f,p)
        _bindings.f = _object.father;

        return new SingletonIterator(new SemiOrphanRel(_bindings.p));
      }
    };
  }