public static Keyword lookupCachedProof(ControlFrame frame) {
    if ((!((BooleanWrapper)(KeyValueList.dynamicSlotValue(Logic.surrogateToDescription(((Surrogate)(frame.proposition.operator))).dynamicSlots, Logic.SYM_LOGIC_CHECK_FOR_CACHED_GOALSp, Stella.FALSE_WRAPPER))).wrapperValue) ||
        (!((Logic.$CACHE_SUCCEEDED_GOALSp$ ||
        Logic.$CACHE_FAILED_GOALSp$) &&
        ((Logic.$DUPLICATE_SUBGOAL_STRATEGY$ == Logic.KWD_DUPLICATE_GOALS) &&
         (!((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
        (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null))))))) {
      return (Logic.KWD_FAILURE);
    }
    { Keyword successorfailure = Logic.KWD_FAILURE;
      AtomicGoalCache cachedgoal = ControlFrame.findCachedGoal(frame, successorfailure);

      if (cachedgoal == null) {
        successorfailure = Logic.KWD_SUCCESS;
        cachedgoal = ControlFrame.findCachedGoal(frame, successorfailure);
      }
      if ((cachedgoal != null) &&
          ((!((Boolean)(Logic.$DONTUSEDEFAULTKNOWLEDGEp$.get())).booleanValue()) ||
           ((cachedgoal.truthValue == Logic.TRUE_TRUTH_VALUE) ||
            (cachedgoal.truthValue == Logic.FALSE_TRUTH_VALUE)))) {
        return (AtomicGoalCache.finishCachedGoalProcessing(cachedgoal, frame, successorfailure, false));
      }
      else {
        return (Logic.KWD_FAILURE);
      }
    }
  }