public static Keyword subsequenceSpecialist(ControlFrame frame, Keyword lastmove) {
    lastmove = lastmove;
    { Vector arguments = frame.proposition.arguments;
      Stella_Object superarg = (arguments.theArray)[0];
      Stella_Object p1Arg = (arguments.theArray)[1];
      Stella_Object p2Arg = (arguments.theArray)[2];
      Stella_Object subarg = (arguments.theArray)[3];
      Iterator iterator = ((Iterator)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_STELLA_ITERATOR, null)));

      if (iterator == null) {
        { Stella_Object superargvalue = Logic.argumentBoundTo(superarg);
          String renamed_Super = (Stella_Object.stringP(superargvalue) ? StringWrapper.unwrapString(((StringWrapper)(superargvalue))) : edu.isi.powerloom.PLI.objectToString(superargvalue));
          int superlength = Stella.NULL_INTEGER;
          Stella_Object p1Argvalue = Logic.argumentBoundTo(p1Arg);
          int p1 = Stella.NULL_INTEGER;
          Stella_Object p2Argvalue = Logic.argumentBoundTo(p2Arg);
          int p2 = Stella.NULL_INTEGER;
          Stella_Object subargvalue = Logic.argumentBoundTo(subarg);
          String sub = (Stella_Object.stringP(subargvalue) ? StringWrapper.unwrapString(((StringWrapper)(subargvalue))) : edu.isi.powerloom.PLI.objectToString(subargvalue));
          int sublength = ((sub != null) ? sub.length() : ((int)(Stella.NULL_INTEGER)));

          if (renamed_Super == null) {
            return (Logic.KWD_FAILURE);
          }
          superlength = renamed_Super.length();
          if (p1Argvalue != null) {
            if (Stella_Object.integerP(p1Argvalue)) {
              p1 = ((IntegerWrapper)(p1Argvalue)).wrapperValue;
            }
            else {
              return (Logic.KWD_TERMINAL_FAILURE);
            }
            if ((p1 < 0) ||
                (p1 > superlength)) {
              return (Logic.KWD_TERMINAL_FAILURE);
            }
          }
          if (p2Argvalue != null) {
            if (Stella_Object.integerP(p2Argvalue)) {
              p2 = ((IntegerWrapper)(p2Argvalue)).wrapperValue;
            }
            else {
              return (Logic.KWD_TERMINAL_FAILURE);
            }
            if (p2 == -1) {
              p2 = superlength;
            }
            if ((p2 > superlength) ||
                ((p1 != Stella.NULL_INTEGER) &&
                 (p1 >= p2))) {
              return (Logic.KWD_TERMINAL_FAILURE);
            }
          }
          if (sub == null) {
            if ((p1 != Stella.NULL_INTEGER) &&
                (p2 != Stella.NULL_INTEGER)) {
              return (Logic.selectProofResult(Logic.bindArgumentToValueP(subarg, StringWrapper.wrapString(Native.string_subsequence(renamed_Super, p1, p2)), true), false, true));
            }
            else {
              return (Logic.KWD_FAILURE);
            }
          }
          else if (p1 == Stella.NULL_INTEGER) {
            if (p2 == Stella.NULL_INTEGER) {
              KeyValueList.setDynamicSlotValue(frame.dynamicSlots, Logic.SYM_STELLA_ITERATOR, SubstringPositionIterator.newSubstringPositionIterator(renamed_Super, sub), null);
            }
            else {
              if (sublength > p2) {
                return (Logic.KWD_TERMINAL_FAILURE);
              }
              else if (Stella.stringEqlP(Native.string_subsequence(renamed_Super, p2 - sublength, p2), sub)) {
                return (Logic.selectProofResult(Logic.bindArgumentToValueP(p1Arg, IntegerWrapper.wrapInteger(p2 - sublength), true), false, true));
              }
              else {
                return (Logic.KWD_TERMINAL_FAILURE);
              }
            }
          }
          else if (p2 == Stella.NULL_INTEGER) {
            if ((p1 + sublength) > superlength) {
              return (Logic.KWD_TERMINAL_FAILURE);
            }
            else if (Stella.stringEqlP(sub, Native.string_subsequence(renamed_Super, p1, p1 + sublength))) {
              return (Logic.selectProofResult(Logic.bindArgumentToValueP(p2Arg, IntegerWrapper.wrapInteger(p1 + sublength), true), false, true));
            }
            else {
              return (Logic.KWD_TERMINAL_FAILURE);
            }
          }
          else {
            { boolean matchP = Logic.bindArgumentToValueP(subarg, StringWrapper.wrapString(Native.string_subsequence(renamed_Super, p1, p2)), true);

              ControlFrame.setFrameTruthValue(frame, (matchP ? Logic.TRUE_TRUTH_VALUE : Logic.FALSE_TRUTH_VALUE));
              return (Logic.selectProofResult(matchP, false, true));
            }
          }
        }
      }
      iterator = ((Iterator)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_STELLA_ITERATOR, null)));
      if (iterator.nextP() &&
          (Logic.bindArgumentToValueP(p1Arg, ((Cons)(iterator.value)).value, true) &&
           Logic.bindArgumentToValueP(p2Arg, ((Cons)(iterator.value)).rest.value, true))) {
        return (Logic.KWD_CONTINUING_SUCCESS);
      }
      else {
        return (Logic.KWD_TERMINAL_FAILURE);
      }
    }
  }