public static Proposition lookupMatchingPropositionInBucket(List bucket, Proposition self, KeyValueMap mapping) {
    { Module homemodule = self.homeContext.baseModule;
      boolean functionP = self.kind == Logic.KWD_FUNCTION;
      GeneralizedSymbol operator = self.operator;
      Vector arguments = self.arguments;
      int arity = arguments.length();
      boolean rewrappedP = false;

      bucket.removeDeletedMembers();
      { Stella_Object p = null;
        Cons iter000 = bucket.theConsList;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          p = iter000.value;
          if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(p), Logic.SGT_LOGIC_PROPOSITION)) {
            { Proposition p000 = ((Proposition)(p));

              if ((operator == p000.operator) &&
                  (arity == p000.arguments.length())) {
                loop001 : for (;;) {
                  if ((functionP &&
                      Proposition.equivalentFunctionPropositionsP(self, p000, mapping)) ||
                      ((!functionP) &&
                       Proposition.equivalentPropositionsP(self, p000, mapping))) {
                    if (Context.subcontextP(homemodule, p000.homeContext.baseModule)) {
                      return (p000);
                    }
                    else {
                      break loop001;
                    }
                  }
                  if (rewrappedP) {
                    break loop001;
                  }
                  else {
                    Proposition.rewrapPropositionArguments(self);
                    rewrappedP = true;
                    continue loop001;
                  }
                }
              }
            }
          }
          else {
          }
        }
      }
      return (null);
    }
  }