public static double queryFoilGain(Cons rule, double utility, List coveredPos, List coveredNeg) {
    { int p = 0;
      int n = 0;
      double result = 0.0;

      { TrainingExample example = null;
        Cons iter000 = coveredNeg.theConsList;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          example = ((TrainingExample)(iter000.value));
          if (Logic.ruleCoversExampleP(rule, example)) {
            n = n + 1;
          }
        }
      }
      { TrainingExample example = null;
        Cons iter001 = coveredPos.theConsList;

        for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
          example = ((TrainingExample)(iter001.value));
          if (Logic.ruleCoversExampleP(rule, example)) {
            p = p + 1;
          }
        }
      }
      if ((p == 0) &&
          (n == 0)) {
        return (0.0);
      }
      result = p * (Logic.foilUtility(p, n) - utility);
      if (result < 1.0e-6) {
        result = 0.0;
      }
      return (result);
    }
  }