public static Cons loomRelatesToKif(Cons tree, Cons implicitvariables) {
    if (tree.value == Logic.SYM_LOGIC_RELATES) {
      tree = tree.rest;
    }
    { Cons clauses = Stella.NIL;
      Cons existsvariables = Stella.NIL;
      Cons arguments = Stella.NIL;
      Cons skolemvariables = Stella.NIL;

      { Symbol v = null;
        Cons iter000 = Logic.SYSTEM_DEFINED_ARGUMENT_NAMES;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          v = ((Symbol)(iter000.value));
          if ((!implicitvariables.memberP(v)) &&
              (skolemvariables.length() < (tree.length() - 1))) {
            skolemvariables = Cons.cons(v, skolemvariables);
          }
        }
      }
      { Stella_Object arg = null;
        Cons iter001 = tree.rest;
        Stella_Object v = null;
        Cons iter002 = skolemvariables;
        Cons collect000 = null;

        loop001 : for (;(!(iter001 == Stella.NIL)) &&
                  (!(iter002 == Stella.NIL)); iter001 = iter001.rest, iter002 = iter002.rest) {
          arg = iter001.value;
          v = iter002.value;
          {
            if (Stella_Object.isaP(arg, Logic.SGT_STELLA_NUMBER_WRAPPER)) {
              arguments = Cons.cons(arg, arguments);
              continue loop001;
            }
            arguments = Cons.cons(v, arguments);
            existsvariables = Cons.cons(v, existsvariables);
          }
          if (collect000 == null) {
            {
              collect000 = Cons.cons(Logic.loomDescriptionToKif(arg, Cons.consList(Cons.cons(((Symbol)(implicitvariables.value)), Cons.cons(v, Stella.NIL)))), Stella.NIL);
              if (clauses == Stella.NIL) {
                clauses = collect000;
              }
              else {
                Cons.addConsToEndOfConsList(clauses, collect000);
              }
            }
          }
          else {
            {
              collect000.rest = Cons.cons(Logic.loomDescriptionToKif(arg, Cons.consList(Cons.cons(((Symbol)(implicitvariables.value)), Cons.cons(v, Stella.NIL)))), Stella.NIL);
              collect000 = collect000.rest;
            }
          }
        }
      }
      return (Cons.list$(Cons.cons(Logic.SYM_STELLA_EXISTS, Cons.cons(existsvariables.reverse(), Cons.cons(Cons.cons(Cons.cons(Logic.SYM_STELLA_AND, clauses.concatenate(Cons.cons(Logic.loomDescriptionToKif(tree.value, arguments.reverse()), Stella.NIL), Stella.NIL)), Stella.NIL), Stella.NIL)))));
    }
  }