public static boolean checkForDuplicateRuleP(ControlFrame frame, Proposition impliesproposition) {
    if (!(Logic.$DUPLICATE_SUBGOAL_STRATEGY$ == Logic.KWD_DUPLICATE_)) {
      return (false);
    }
    { ControlFrame previousframe = frame.up;
      Cons goalbindings = Proposition.yieldGoalBindings(frame.proposition);

      { int i = Stella.NULL_INTEGER;
        int iter000 = 1;
        int upperBound000 = Logic.$DUPLICATE_RULE_SEARCH_DEPTH$;
        boolean unboundedP000 = upperBound000 == Stella.NULL_INTEGER;

        for (;unboundedP000 ||
                  (iter000 <= upperBound000); iter000 = iter000 + 1) {
          i = iter000;
          i = i;
          if (previousframe == null) {
            return (false);
          }
          { boolean testValue000 = false;

            testValue000 = ((Proposition)(KeyValueList.dynamicSlotValue(previousframe.dynamicSlots, Logic.SYM_LOGIC_ANTECEDENTS_RULE, null))) == impliesproposition;
            if (testValue000) {
              { boolean alwaysP000 = true;

                { Stella_Object b1 = null;
                  Cons iter001 = goalbindings;
                  Stella_Object b2 = null;
                  Cons iter002 = Proposition.yieldGoalBindings(previousframe.proposition);

                  loop001 : for (;(!(iter001 == Stella.NIL)) &&
                            (!(iter002 == Stella.NIL)); iter001 = iter001.rest, iter002 = iter002.rest) {
                    b1 = iter001.value;
                    b2 = iter002.value;
                    if (!Stella_Object.eqlP(b1, b2)) {
                      alwaysP000 = false;
                      break loop001;
                    }
                  }
                }
                testValue000 = alwaysP000;
              }
              if (testValue000) {
                testValue000 = frame.reversePolarityP == previousframe.reversePolarityP;
              }
            }
            if (testValue000) {
              if ((Stella.$TRACED_KEYWORDS$ != null) &&
                  Stella.$TRACED_KEYWORDS$.membP(Logic.KWD_GOAL_CACHES)) {
                System.out.println("DUPLICATE RULE.  BINDINGS: " + goalbindings);
              }
              if (false) {
                ControlFrame.establishGoalCache(frame);
              }
              return (true);
            }
          }
          previousframe = previousframe.up;
        }
      }
    }
    return (false);
  }