public static List linkVariablesInInducedRule(Cons rule, List examples, Vector consProps) {
    { List vars = null;
      Cons tempRule = Stella.NIL;
      Symbol var = null;
      List unlinked = null;
      List linked = null;
      List newRules = List.newList();

      vars = Logic.getVariablesFromConsPropositions(rule);
      { TrainingExample example = null;
        Cons iter000 = examples.theConsList;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          example = ((TrainingExample)(iter000.value));
          if (example.input == null) {
            example.input = Logic.createInputSignature(example.query);
          }
          tempRule = ((Cons)(Stella_Object.copyConsTree(rule)));
          unlinked = List.newList();
          linked = List.newList();
          { Symbol var000 = null;
            Cons iter001 = vars.theConsList;
            Cons collect000 = null;

            for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
              var000 = ((Symbol)(iter001.value));
              if (collect000 == null) {
                {
                  collect000 = Cons.cons(var000, Stella.NIL);
                  if (unlinked.theConsList == Stella.NIL) {
                    unlinked.theConsList = collect000;
                  }
                  else {
                    Cons.addConsToEndOfConsList(unlinked.theConsList, collect000);
                  }
                }
              }
              else {
                {
                  collect000.rest = Cons.cons(var000, Stella.NIL);
                  collect000 = collect000.rest;
                }
              }
            }
          }
          unlinked = ((List)(unlinked.remove(Logic.SYM_LOGIC_pY)));
          linked.push(Logic.SYM_LOGIC_pY);
          while (!unlinked.emptyP()) {
            var = ((Symbol)(unlinked.pop()));
            { Cons prop = null;
              Vector vector000 = consProps;
              int index000 = 0;
              int length000 = vector000.length();
              int i = Stella.NULL_INTEGER;
              int iter002 = 0;

              loop003 : for (;index000 < length000; index000 = index000 + 1, iter002 = iter002 + 1) {
                prop = ((Cons)((vector000.theArray)[index000]));
                i = iter002;
                if (prop.memberP(var)) {
                  { boolean foundP000 = false;

                    { Stella_Object ele = null;
                      Cons iter003 = tempRule;

                      loop004 : for (;!(iter003 == Stella.NIL); iter003 = iter003.rest) {
                        ele = iter003.value;
                        if (Stella_Object.equalConsTreesP(ele, prop)) {
                          foundP000 = true;
                          break loop004;
                        }
                      }
                    }
                    if (foundP000) {
                      linked.push(var);
                      break loop003;
                    }
                  }
                  if (Stella_Object.eqlP((example.input.theArray)[i], Stella.ONE_WRAPPER)) {
                    tempRule = tempRule.concatenate(Cons.consList(Cons.cons(((Cons)(Stella_Object.copyConsTree(prop))), Stella.NIL)), Stella.NIL);
                    { Stella_Object newVar = null;
                      Cons iter004 = prop.rest;

                      for (;!(iter004 == Stella.NIL); iter004 = iter004.rest) {
                        newVar = iter004.value;
                        if ((!(newVar == var)) &&
                            (Stella_Object.symbolP(newVar) &&
                             (!linked.memberP(newVar)))) {
                          unlinked.push(((Symbol)(newVar)));
                        }
                      }
                    }
                    linked.push(var);
                    break loop003;
                  }
                }
              }
            }
          }
          { boolean testValue000 = false;

            { boolean foundP001 = false;

              { Cons ele = null;
                Cons iter005 = newRules.theConsList;

                loop006 : for (;!(iter005 == Stella.NIL); iter005 = iter005.rest) {
                  ele = ((Cons)(iter005.value));
                  if (Stella_Object.equalConsTreesP(ele, tempRule)) {
                    foundP001 = true;
                    break loop006;
                  }
                }
              }
              testValue000 = foundP001;
            }
            testValue000 = !testValue000;
            if (testValue000) {
              newRules.push(tempRule);
            }
          }
        }
      }
      { ListIterator it = ((ListIterator)(newRules.allocateIterator()));

        while (it.nextP()) {
          it.valueSetter(((Cons)(((Cons)(it.value)))).reverse());
        }
      }
      return (newRules);
    }
  }