public static double trainAndTestCaseMatcher(Symbol className, Symbol slotName, int numTrain, int numTest, int cycles) {
    className = ((Symbol)(className.permanentify()));
    slotName = ((Symbol)(slotName.permanentify()));
    { Surrogate renamed_Class = Logic.getDescription(className).surrogateValueInverse;
      List cases = Logic.allClassInstances(renamed_Class).listify();
      Vector instances = Vector.newVector(numTrain);
      Surrogate slot = Logic.getDescription(slotName).surrogateValueInverse;
      Vector slotValues = Vector.newVector(cases.length());
      int numCorrect = 0;

      Logic.shuffleList(cases);
      { Stella_Object renamed_Case = null;
        Cons iter000 = cases.theConsList;
        int i = Stella.NULL_INTEGER;
        int iter001 = 0;
        int upperBound000 = numTrain - 1;

        for (;(!(iter000 == Stella.NIL)) &&
                  (iter001 <= upperBound000); iter000 = iter000.rest, iter001 = iter001 + 1) {
          renamed_Case = iter000.value;
          i = iter001;
          (instances.theArray)[i] = (((LogicObject)(renamed_Case)));
        }
      }
      Logic.generateCaseRuleWoSlot(instances, className, slotName);
      QueryIterator.returnPartialTruth(Logic.makeQuery(Stella.NIL, Logic.coerceToTree(Cons.list$(Cons.cons(Logic.SYM_LOGIC_CASE_MATCH, Cons.cons(Logic.objectName(cases.first()), Cons.cons(Cons.cons(Cons.list$(Cons.cons(Logic.SYM_LOGIC_OBJECT_NAME, Cons.cons(Cons.list$(Cons.cons(Logic.SYM_STELLA_SECOND, Cons.cons(Logic.SYM_LOGIC_CASES, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL), Stella.NIL))))), Stella.NIL, Stella.NIL), true);
      Logic.saveAllNeuralNetworks(Logic.$SAVE_NETWORK_FILE$);
      System.out.println("Training case matcher");
      { int numInstances = Logic.generateCaseTrainingExamples(instances, slot);

        Logic.trainNeuralNetwork(cycles, numInstances * Logic.$NUM_TRAINING_PER_CASE$);
      }
      { List trainingCases = List.newList();

        { int i = Stella.NULL_INTEGER;
          int iter002 = 0;
          int upperBound001 = numTrain - 1;
          Cons collect000 = null;

          for (;iter002 <= upperBound001; iter002 = iter002 + 1) {
            i = iter002;
            if (collect000 == null) {
              {
                collect000 = Cons.cons(((LogicObject)((instances.theArray)[i])), Stella.NIL);
                if (trainingCases.theConsList == Stella.NIL) {
                  trainingCases.theConsList = collect000;
                }
                else {
                  Cons.addConsToEndOfConsList(trainingCases.theConsList, collect000);
                }
              }
            }
            else {
              {
                collect000.rest = Cons.cons(((LogicObject)((instances.theArray)[i])), Stella.NIL);
                collect000 = collect000.rest;
              }
            }
          }
        }
        { int i = Stella.NULL_INTEGER;
          int iter003 = numTrain;
          int upperBound002 = (numTrain + numTest) - 1;

          for (;iter003 <= upperBound002; iter003 = iter003 + 1) {
            i = iter003;
            { Stella_Object probe = cases.nth(i);
              Stella_Object correctAnswer = (slotValues.theArray)[i];
              Stella_Object answer = LogicObject.generateCaseBasedAnswer(((LogicObject)(probe)), slot, trainingCases);

              System.out.println(probe + "  Predicted: " + answer + ", Correct: " + correctAnswer);
              if (Stella_Object.eqlP(answer, correctAnswer)) {
                numCorrect = numCorrect + 1;
              }
            }
          }
        }
      }
      return (((double)(numCorrect)) / numTest);
    }
  }