public static Iterator allocateAntecedentsIterator(Description goaldescription, Vector externalarguments, boolean reversepolarityP) {
    { Cons antecedents = Stella.NIL;
      LogicObject antecedent = null;
      boolean incompatibleargumentsP = false;

      { Proposition prop = null;
        Cons iter000 = LogicObject.applicableRulesOfDescription(goaldescription, (reversepolarityP ? Logic.KWD_FORWARD : Logic.KWD_BACKWARD), false);

        loop000 : for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          prop = ((Proposition)(iter000.value));
          if (((reversepolarityP ? (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(prop.dynamicSlots, Logic.SYM_LOGIC_BACKWARD_ONLYp, Stella.FALSE_WRAPPER))).wrapperValue) : (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(prop.dynamicSlots, Logic.SYM_LOGIC_FORWARD_ONLYp, Stella.FALSE_WRAPPER))).wrapperValue))) &&
              ((!reversepolarityP) ||
               (Description.atomicGoalDescriptionP(((Description)((prop.arguments.theArray)[1]))) ||
                Logic.closedTermP((prop.arguments.theArray)[1])))) {
            antecedent = (reversepolarityP ? ((LogicObject)((prop.arguments.theArray)[1])) : ((LogicObject)((prop.arguments.theArray)[0])));
            if ((!Stella_Object.isaP(antecedent, Logic.SGT_LOGIC_DESCRIPTION)) ||
                (!(externalarguments.length() == ((Description)(antecedent)).ioVariables.length()))) {
              continue loop000;
            }
            incompatibleargumentsP = false;
            { PatternVariable v = null;
              Vector vector000 = ((Description)(antecedent)).ioVariables;
              int index000 = 0;
              int length000 = vector000.length();
              Stella_Object arg = null;
              Vector vector001 = externalarguments;
              int index001 = 0;
              int length001 = vector001.length();

              loop001 : for (;(index000 < length000) &&
                        (index001 < length001); index000 = index000 + 1, index001 = index001 + 1) {
                v = ((PatternVariable)((vector000.theArray)[index000]));
                arg = (vector001.theArray)[index001];
                { Stella_Object argvalue = Logic.argumentBoundTo(arg);
                  Stella_Object varvalue = Logic.groundValueOf(v);

                  if ((argvalue != null) &&
                      (((varvalue != null) &&
                      (!Stella_Object.eqlP(argvalue, varvalue))) ||
                       ((varvalue == null) &&
                        PatternVariable.failsAntecedentTypeCheckP(v, argvalue)))) {
                    incompatibleargumentsP = true;
                    break loop001;
                  }
                }
              }
            }
            if (!incompatibleargumentsP) {
              antecedents = Cons.cons(prop, antecedents);
            }
          }
        }
      }
      if (antecedents == Stella.NIL) {
        return (null);
      }
      else {
        return (Logic.optimizeOrderOfApplicableRules(antecedents, !reversepolarityP).allocateIterator());
      }
    }
  }