public static int generateTrainingExamples(Vector instances, Surrogate concept) {
    { int numInstances = instances.length();
      Cons consQuery = Stella.NIL;
      int numExamples = 0;
      TrainingExample example = null;
      Proposition prop = null;
      QueryIterator query = null;
      Symbol conceptName = Symbol.internSymbol(concept.symbolName);

      { int i = Stella.NULL_INTEGER;
        int iter000 = 0;
        int upperBound000 = numInstances - 1;

        for (;iter000 <= upperBound000; iter000 = iter000 + 1) {
          i = iter000;
          consQuery = Cons.consList(Cons.cons(conceptName, Cons.cons(Logic.objectName(((LogicObject)((instances.theArray)[i]))), Stella.NIL)));
          prop = ((Proposition)(Logic.conceiveFormula(((Cons)(Stella_Object.copyConsTree(consQuery))))));
          example = null;
          if (Proposition.trueP(prop)) {
            {
              Proposition.helpUpdateTopLevelProposition(prop, Logic.KWD_RETRACT_TRUE);
              query = Logic.makeQuery(Stella.NIL, ((Cons)(Stella_Object.copyConsTree(consQuery))), Stella.NIL, Stella.NIL);
              if (TruthValue.unknownTruthValueP(Logic.callAsk(query))) {
                example = TrainingExample.newTrainingExample();
                example.query = consQuery;
                example.output = Stella.TRUE_WRAPPER;
                example.concept = conceptName;
                example.name = Logic.objectName(((LogicObject)((instances.theArray)[i])));
                example.score = 1.0;
              }
              Proposition.helpUpdateTopLevelProposition(prop, Logic.KWD_ASSERT_TRUE);
            }
          }
          else {
            if (Proposition.falseP(prop) ||
                Logic.$CLOSED_WORLD_TRAINING_EXAMPLES$) {
              {
                example = TrainingExample.newTrainingExample();
                example.query = consQuery;
                example.output = Stella.FALSE_WRAPPER;
                example.concept = conceptName;
                example.name = Logic.objectName(((LogicObject)((instances.theArray)[i])));
                example.score = 0.0;
              }
            }
          }
          if (!(example == null)) {
            example.module = ((Module)(Stella.$MODULE$.get()));
            example.timestamp = -1;
            numExamples = numExamples + 1;
            Logic.$TRAINING_EXAMPLES$.push(example);
          }
        }
      }
      return (numExamples);
    }
  }