public static Cons loomDescriptionToKif(Stella_Object tree, Cons implicitvariables) {
    if (Stella_Object.safePrimaryType(tree) == Logic.SGT_STELLA_CONS) {
      { Cons tree000 = ((Cons)(tree));

        { Stella_Object operator = tree000.value;

          { GeneralizedSymbol testValue000 = ((GeneralizedSymbol)(operator));

            if ((testValue000 == Logic.SYM_STELLA_AND) ||
                ((testValue000 == Logic.SYM_STELLA_OR) ||
                 (testValue000 == Logic.SYM_STELLA_NOT))) {
              { Cons clauses = Stella.NIL;

                { Stella_Object arg = null;
                  Cons iter000 = tree000.rest;
                  Cons collect000 = null;

                  for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
                    arg = iter000.value;
                    if (collect000 == null) {
                      {
                        collect000 = Cons.cons(Logic.loomDescriptionToKif(arg, implicitvariables), Stella.NIL);
                        if (clauses == Stella.NIL) {
                          clauses = collect000;
                        }
                        else {
                          Cons.addConsToEndOfConsList(clauses, collect000);
                        }
                      }
                    }
                    else {
                      {
                        collect000.rest = Cons.cons(Logic.loomDescriptionToKif(arg, implicitvariables), Stella.NIL);
                        collect000 = collect000.rest;
                      }
                    }
                  }
                }
                return (Cons.cons(operator, clauses.concatenate(Stella.NIL, Stella.NIL)));
              }
            }
            else if ((testValue000 == Logic.SYM_LOGIC_AT_LEAST) ||
                ((testValue000 == Logic.SYM_LOGIC_AT_MOST) ||
                 ((testValue000 == Logic.SYM_LOGIC_EXACTLY) ||
                  ((testValue000 == Logic.SYM_LOGIC_ALL) ||
                   ((testValue000 == Logic.SYM_STELLA_SOME) ||
                    ((testValue000 == Logic.SYM_LOGIC_THE) ||
                     ((testValue000 == Logic.SYM_LOGIC_FILLED_BY) ||
                      (testValue000 == Logic.SYM_LOGIC_FILLERS)))))))) {
              return (Logic.loomRestrictionToKif(tree000, ((Symbol)(implicitvariables.value))));
            }
            else if (testValue000 == Logic.SYM_LOGIC_SAME_AS) {
              { Symbol selfvariable = ((Symbol)(implicitvariables.value));
                Symbol y = null;

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

                  loop001 : for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
                    v = ((Symbol)(iter001.value));
                    if (!(v == selfvariable)) {
                      y = v;
                      break loop001;
                    }
                  }
                }
                { Cons localimplicitvariables = Cons.consList(Cons.cons(selfvariable, Cons.cons(y, Stella.NIL)));
                  Cons clauses = Stella.NIL;

                  { Stella_Object arg = null;
                    Cons iter002 = tree000.rest;
                    Cons collect001 = null;

                    for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
                      arg = iter002.value;
                      if (collect001 == null) {
                        {
                          collect001 = Cons.cons(Logic.loomDescriptionToKif(arg, localimplicitvariables), Stella.NIL);
                          if (clauses == Stella.NIL) {
                            clauses = collect001;
                          }
                          else {
                            Cons.addConsToEndOfConsList(clauses, collect001);
                          }
                        }
                      }
                      else {
                        {
                          collect001.rest = Cons.cons(Logic.loomDescriptionToKif(arg, localimplicitvariables), Stella.NIL);
                          collect001 = collect001.rest;
                        }
                      }
                    }
                  }
                  return (Cons.list$(Cons.cons(Logic.SYM_STELLA_EXISTS, Cons.cons(y, Cons.cons(Cons.cons(Cons.cons(Logic.SYM_STELLA_AND, clauses.concatenate(Stella.NIL, Stella.NIL)), Stella.NIL), Stella.NIL)))));
                }
              }
            }
            else if ((testValue000 == Logic.SYM_LOGIC_RELATES) ||
                ((testValue000 == Logic.SYM_STELLA_g) ||
                 ((testValue000 == Logic.SYM_STELLA_l) ||
                  ((testValue000 == Logic.SYM_STELLA_ge) ||
                   ((testValue000 == Logic.SYM_STELLA_le) ||
                    ((testValue000 == Logic.SYM_LOGIC_lg) ||
                     (testValue000 == Logic.SYM_STELLA_e))))))) {
              return (Logic.loomRelatesToKif(tree000, implicitvariables));
            }
            else if (testValue000 == Logic.SYM_LOGIC_ONE_OF) {
              return (Cons.cons(Logic.SYM_PL_KERNEL_KB_MEMBER_OF, Cons.copyConsList(implicitvariables).concatenate(Cons.cons(Cons.cons(Logic.SYM_STELLA_SETOF, tree000.rest.concatenate(Stella.NIL, Stella.NIL)), Stella.NIL), Stella.NIL)));
            }
            else if (testValue000 == Logic.SYM_LOGIC_THE_ORDERED_SET) {
              return (Cons.cons(Logic.SYM_PL_KERNEL_KB_MEMBER_OF, Cons.copyConsList(implicitvariables).concatenate(Cons.cons(Cons.cons(Logic.SYM_LOGIC_LISTOF, tree000.rest.concatenate(Stella.NIL, Stella.NIL)), Stella.NIL), Stella.NIL)));
            }
            else if ((testValue000 == Logic.SYM_LOGIC_THROUGH) ||
                ((testValue000 == Logic.SYM_LOGIC_INTERVALii) ||
                 ((testValue000 == Logic.SYM_LOGIC_INTERVALi_) ||
                  ((testValue000 == Logic.SYM_LOGIC_INTERVAL_i) ||
                   (testValue000 == Logic.SYM_LOGIC_INTERVAL__))))) {
              return (Logic.loomThroughToKif(tree000, implicitvariables));
            }
            else if (testValue000 == Logic.SYM_LOGIC_SATISFIES) {
              return (Logic.loomSatisfiesToKif(tree000, implicitvariables));
            }
            else if (testValue000 == Logic.SYM_LOGIC_DOMAIN) {
              return (Logic.loomDescriptionToKif(tree000.rest.value, Cons.consList(Cons.cons(((Symbol)(implicitvariables.value)), Stella.NIL))));
            }
            else if (testValue000 == Logic.SYM_LOGIC_DOMAINS) {
              { Cons clauses = Stella.NIL;

                { Stella_Object domain = null;
                  Cons iter003 = tree000.rest;
                  Symbol var = null;
                  Cons iter004 = implicitvariables;
                  Cons collect002 = null;

                  for (;(!(iter003 == Stella.NIL)) &&
                            (!(iter004 == Stella.NIL)); iter003 = iter003.rest, iter004 = iter004.rest) {
                    domain = iter003.value;
                    var = ((Symbol)(iter004.value));
                    if (collect002 == null) {
                      {
                        collect002 = Cons.cons(Logic.loomDescriptionToKif(domain, Cons.consList(Cons.cons(var, Stella.NIL))), Stella.NIL);
                        if (clauses == Stella.NIL) {
                          clauses = collect002;
                        }
                        else {
                          Cons.addConsToEndOfConsList(clauses, collect002);
                        }
                      }
                    }
                    else {
                      {
                        collect002.rest = Cons.cons(Logic.loomDescriptionToKif(domain, Cons.consList(Cons.cons(var, Stella.NIL))), Stella.NIL);
                        collect002 = collect002.rest;
                      }
                    }
                  }
                }
                return (((Cons)(Logic.conjoinSentences(clauses))));
              }
            }
            else if (testValue000 == Logic.SYM_LOGIC_RANGE) {
              return (Logic.loomDescriptionToKif(tree000.rest.value, Cons.consList(Cons.cons(((Symbol)(implicitvariables.last())), Stella.NIL))));
            }
            else if ((testValue000 == Logic.SYM_STELLA_INVERSE) ||
                (testValue000 == Logic.SYM_PL_KERNEL_KB_INVERSE)) {
              { Cons inverseimplicitvariables = Cons.consList(Cons.cons(((Symbol)(implicitvariables.rest.value)), Cons.cons(((Symbol)(implicitvariables.value)), Stella.NIL)));

                return (Logic.loomDescriptionToKif(tree000.rest.value, inverseimplicitvariables));
              }
            }
            else if (testValue000 == Logic.SYM_LOGIC_COMPOSE) {
              { Cons chain = Cons.cons(tree000.rest.value, Cons.cons(((Symbol)(implicitvariables.value)), Stella.NIL));

                { Stella_Object function = null;
                  Cons iter005 = tree000.rest.rest;

                  for (;!(iter005 == Stella.NIL); iter005 = iter005.rest) {
                    function = iter005.value;
                    chain = Cons.cons(function, Cons.cons(chain, Stella.NIL));
                  }
                }
                return (chain.concatenate(Cons.cons(((Symbol)(implicitvariables.rest.value)), Stella.NIL), Stella.NIL));
              }
            }
            else {
              {
                System.out.println("Illegal or unimplemented Loom operator cannot be translated to KIF.");
                System.out.println("   Problem expression:  `" + tree000 + "'");
                System.out.println();
              }
;
              return (Stella.NIL);
            }
          }
        }
      }
    }
    else {
      if (((GeneralizedSymbol)(tree)) == Logic.SYM_LOGIC_lg) {
        return (Cons.list$(Cons.cons(Logic.SYM_STELLA_NOT, Cons.cons(Cons.cons(Logic.SYM_STELLA_e, Cons.copyConsList(implicitvariables).concatenate(Stella.NIL, Stella.NIL)), Cons.cons(Stella.NIL, Stella.NIL)))));
      }
      else {
        return (Cons.cons(tree, Cons.copyConsList(implicitvariables).concatenate(Stella.NIL, Stella.NIL)));
      }
    }
  }