public static boolean overlayWithPatternFrameP(ControlFrame frame, Description description, Vector ioarguments) {
    { Cons iobindings = Logic.computeExternalBindings(ioarguments);
      Cons externalbindings = ((((Vector)(KeyValueList.dynamicSlotValue(description.dynamicSlots, Logic.SYM_LOGIC_EXTERNAL_VARIABLES, null))) != null) ? Logic.computeExternalBindings(((Vector)(KeyValueList.dynamicSlotValue(description.dynamicSlots, Logic.SYM_LOGIC_EXTERNAL_VARIABLES, null)))) : Stella.NIL);
      PatternRecord patternrecord = ControlFrame.createPatternRecord(frame, description, ioarguments);
      Description optimalpattern = null;

      if (ioarguments == null) {
        { Iterator v = ((Iterator)(description.ioVariables.allocateIterator()));
          Cons collect000 = null;

          while (v.nextP()) {
            if (collect000 == null) {
              {
                collect000 = Cons.cons(null, Stella.NIL);
                if (iobindings == Stella.NIL) {
                  iobindings = collect000;
                }
                else {
                  Cons.addConsToEndOfConsList(iobindings, collect000);
                }
              }
            }
            else {
              {
                collect000.rest = Cons.cons(null, Stella.NIL);
                collect000 = collect000.rest;
              }
            }
          }
        }
      }
      frame.state = Logic.KWD_PATTERN;
      optimalpattern = Description.selectOptimalQueryPattern(description, patternrecord.booleanVector, frame);
      patternrecord.optimalPattern = optimalpattern;
      if (Description.checkForSingleValuedGoalP(optimalpattern, iobindings)) {
        KeyValueList.setDynamicSlotValue(frame.dynamicSlots, Logic.SYM_LOGIC_CACHED_SINGLE_VALUEDp, Stella.TRUE_WRAPPER, Stella.FALSE_WRAPPER);
      }
      frame.proposition = optimalpattern.proposition;
      { int variablescount = iobindings.length() + optimalpattern.internalVariables.length() + externalbindings.length();

        PatternRecord.activatePatternRecord(patternrecord, variablescount);
      }
      { PatternVariable iovar = null;
        Vector vector000 = optimalpattern.ioVariables;
        int index000 = 0;
        int length000 = vector000.length();
        Stella_Object binding = null;
        Cons iter000 = iobindings;

        for (;(index000 < length000) &&
                  (!(iter000 == Stella.NIL)); index000 = index000 + 1, iter000 = iter000.rest) {
          iovar = ((PatternVariable)((vector000.theArray)[index000]));
          binding = iter000.value;
          if ((binding != null) &&
              (!PatternVariable.bindVariableToValueP(iovar, binding, false))) {
            return (false);
          }
        }
      }
      if (!(externalbindings == Stella.NIL)) {
        { PatternVariable externalvar = null;
          Vector vector001 = ((Vector)(KeyValueList.dynamicSlotValue(optimalpattern.dynamicSlots, Logic.SYM_LOGIC_EXTERNAL_VARIABLES, null)));
          int index001 = 0;
          int length001 = vector001.length();
          Stella_Object binding = null;
          Cons iter001 = externalbindings;

          for (;(index001 < length001) &&
                    (!(iter001 == Stella.NIL)); index001 = index001 + 1, iter001 = iter001.rest) {
            externalvar = ((PatternVariable)((vector001.theArray)[index001]));
            binding = iter001.value;
            if ((binding != null) &&
                (!PatternVariable.bindVariableToValueP(externalvar, binding, false))) {
              return (false);
            }
          }
        }
      }
      if (frame.down == null) {
        ControlFrame.createDownFrame(frame, optimalpattern.proposition);
      }
      Proposition.elaborateSurrogatesInProposition(optimalpattern.proposition);
      return (true);
    }
  }