public static void recordPatternJustification(ControlFrame frame, Keyword lastmove) {
    { ControlFrame argument = frame.result;
      Justification justification = ((Justification)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_LOGIC_JUSTIFICATION, null)));

      if ((lastmove == Logic.KWD_UP_TRUE) ||
          (lastmove == Logic.KWD_UP_FAIL)) {
        if (((Justification)(KeyValueList.dynamicSlotValue(argument.dynamicSlots, Logic.SYM_LOGIC_JUSTIFICATION, null))) == null) {
          return;
        }
        if (justification == null) {
          { Justification self000 = Justification.newJustification();

            self000.inferenceRule = Logic.KWD_PATTERN;
            ControlFrame.recordGoalJustification(frame, self000);
          }
          justification = ((Justification)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_LOGIC_JUSTIFICATION, null)));
        }
        { KeyValueMap substitution = KeyValueMap.newKeyValueMap();
          PatternRecord patternrecord = frame.patternRecord;
          Description description = null;
          boolean collectionframeP = false;

          if (patternrecord != null) {
            collectionframeP = patternrecord.collectionList != null;
            description = patternrecord.optimalPattern;
            if (description != null) {
              { PatternVariable vbl = null;
                Vector vector000 = description.ioVariables;
                int index000 = 0;
                int length000 = vector000.length();

                for (;index000 < length000; index000 = index000 + 1) {
                  vbl = ((PatternVariable)((vector000.theArray)[index000]));
                  substitution.insertAt(vbl, (((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord.variableBindings.theArray)[(vbl.boundToOffset)]);
                }
              }
              { PatternVariable vbl = null;
                Vector vector001 = description.internalVariables;
                int index001 = 0;
                int length001 = vector001.length();

                for (;index001 < length001; index001 = index001 + 1) {
                  vbl = ((PatternVariable)((vector001.theArray)[index001]));
                  substitution.insertAt(vbl, (((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord.variableBindings.theArray)[(vbl.boundToOffset)]);
                }
              }
            }
          }
          if (Stella_Object.isaP(substitution, Logic.SGT_STELLA_KEY_VALUE_LIST)) {
            { KeyValueMap oldsubstitution = substitution;

              substitution = KeyValueMap.newKeyValueMap();
              { Stella_Object key = null;
                Stella_Object val = null;
                DictionaryIterator iter000 = ((DictionaryIterator)(oldsubstitution.allocateIterator()));

                while (iter000.nextP()) {
                  key = iter000.key;
                  val = iter000.value;
                  substitution.insertAt(key, val);
                }
              }
            }
          }
          justification.substitution = ((KeyValueMap)(substitution));
          { Justification antecedent = ((Justification)(KeyValueList.dynamicSlotValue(argument.dynamicSlots, Logic.SYM_LOGIC_JUSTIFICATION, null)));

            if (collectionframeP) {
              justification.inferenceRule = Logic.KWD_AND_INTRODUCTION;
              { Justification patterncopy = null;

                { Justification self004 = Justification.newJustification();

                  self004.inferenceRule = Logic.KWD_PATTERN;
                  self004.antecedents = Cons.cons(antecedent, Stella.NIL);
                  ControlFrame.recordGoalJustification(frame, self004);
                }
                patterncopy = ((Justification)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_LOGIC_JUSTIFICATION, null)));
                KeyValueList.setDynamicSlotValue(frame.dynamicSlots, Logic.SYM_LOGIC_JUSTIFICATION, justification, null);
                Justification.backlinkToPatternJustification(antecedent, patterncopy);
                Justification.backlinkToPatternJustification(patterncopy, justification);
                patterncopy.substitution = ((KeyValueMap)(substitution));
                justification.substitution = null;
                antecedent = patterncopy;
              }
            }
            justification.antecedents = Cons.cons(antecedent, justification.antecedents);
            if (!(collectionframeP)) {
              Justification.backlinkToPatternJustification(antecedent, justification);
            }
          }
        }
      }
      else {
      }
    }
  }