public static Cons loomRestrictionToKif(Cons tree, Symbol implicitvariable) {
    { Symbol operator = ((Symbol)(tree.value));
      Stella_Object role = null;
      Stella_Object argument = null;
      Symbol existsvariable = null;
      Stella_Object qualification = tree.fourth();

      if (Stella.getQuotedTree("((AT-LEAST AT-MOST EXACTLY) \"/LOGIC\")", "/LOGIC").memberP(operator)) {
        {
          argument = tree.rest.value;
          role = tree.rest.rest.value;
        }
      }
      else {
        {
          role = tree.rest.value;
          argument = tree.rest.rest.value;
        }
      }
      if ((operator == Logic.SYM_LOGIC_AT_LEAST) ||
          ((operator == Logic.SYM_LOGIC_AT_MOST) ||
           (operator == Logic.SYM_LOGIC_EXACTLY))) {
        if (qualification != null) {
          if (operator == Logic.SYM_LOGIC_AT_LEAST) {
            operator = Logic.SYM_PL_KERNEL_KB_QUALIFIED_RANGE_CARDINALITY_LOWER_BOUND;
          }
          else if (operator == Logic.SYM_LOGIC_AT_MOST) {
            operator = Logic.SYM_PL_KERNEL_KB_QUALIFIED_RANGE_CARDINALITY_UPPER_BOUND;
          }
          else if (operator == Logic.SYM_LOGIC_EXACTLY) {
            operator = Logic.SYM_PL_KERNEL_KB_QUALIFIED_RANGE_CARDINALITY;
          }
          else {
            { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

              stream000.nativeStream.print("`" + operator + "' is not a valid case option");
              throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
            }
          }
        }
        else {
          if (operator == Logic.SYM_LOGIC_AT_LEAST) {
            operator = Logic.SYM_PL_KERNEL_KB_RANGE_CARDINALITY_LOWER_BOUND;
          }
          else if (operator == Logic.SYM_LOGIC_AT_MOST) {
            operator = Logic.SYM_PL_KERNEL_KB_RANGE_CARDINALITY_UPPER_BOUND;
          }
          else if (operator == Logic.SYM_LOGIC_EXACTLY) {
            operator = Logic.SYM_PL_KERNEL_KB_RANGE_CARDINALITY;
          }
          else {
            { OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

              stream001.nativeStream.print("`" + operator + "' is not a valid case option");
              throw ((StellaException)(StellaException.newStellaException(stream001.theStringReader()).fillInStackTrace()));
            }
          }
        }
        return (Cons.cons(operator, Cons.cons(Logic.loomArgumentDescriptionToKif(role, Logic.KWD_BINARY), Cons.cons(implicitvariable, Cons.cons(argument, (((qualification != null) ? Cons.consList(Cons.cons(Logic.loomArgumentDescriptionToKif(qualification, Logic.KWD_UNARY), Stella.NIL)) : Stella.NIL)).concatenate(Stella.NIL, Stella.NIL))))));
      }
      else if (operator == Logic.SYM_LOGIC_ALL) {
        if (qualification != null) {
          {
            { Symbol v = null;
              Cons iter000 = Logic.SYSTEM_DEFINED_ARGUMENT_NAMES;

              loop000 : for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
                v = ((Symbol)(iter000.value));
                if (!(implicitvariable == v)) {
                  existsvariable = v;
                  break loop000;
                }
              }
            }
            return (Cons.list$(Cons.cons(Logic.SYM_STELLA_EXISTS, Cons.cons(Cons.cons(existsvariable, Stella.NIL), Cons.cons(Cons.list$(Cons.cons(Logic.SYM_STELLA_eg, Cons.cons(Cons.list$(Cons.cons(Logic.SYM_STELLA_AND, Cons.cons(Cons.cons(Logic.loomArgumentDescriptionToKif(role, Logic.KWD_BINARY), Cons.cons(implicitvariable, Cons.cons(existsvariable, Stella.NIL))), Cons.cons(Cons.cons(Logic.loomArgumentDescriptionToKif(qualification, Logic.KWD_UNARY), Cons.cons(existsvariable, Stella.NIL)), Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.cons(Logic.loomArgumentDescriptionToKif(argument, Logic.KWD_UNARY), Cons.cons(((Symbol)(Logic.SYSTEM_DEFINED_ARGUMENT_NAMES.nth(0))), Stella.NIL)), Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Stella.NIL, Stella.NIL))))));
          }
        }
        else {
          return (Cons.list$(Cons.cons(Logic.SYM_PL_KERNEL_KB_RANGE_TYPE, Cons.cons(Logic.loomArgumentDescriptionToKif(role, Logic.KWD_BINARY), Cons.cons(Cons.cons(implicitvariable, Cons.cons(Logic.loomArgumentDescriptionToKif(argument, Logic.KWD_UNARY), Stella.NIL)), Stella.NIL)))));
        }
      }
      else if (operator == Logic.SYM_STELLA_SOME) {
        return (Logic.loomRestrictionToKif(Cons.list$(Cons.cons(Logic.SYM_LOGIC_AT_LEAST, Cons.cons(IntegerWrapper.wrapInteger(1), Cons.cons(role, Cons.cons(Cons.cons(argument, Stella.NIL), Stella.NIL))))), implicitvariable));
      }
      else if (operator == Logic.SYM_LOGIC_THE) {
        return (Logic.loomDescriptionToKif(Cons.list$(Cons.cons(Logic.SYM_STELLA_AND, Cons.cons(Cons.list$(Cons.cons(Logic.SYM_LOGIC_EXACTLY, Cons.cons(IntegerWrapper.wrapInteger(1), Cons.cons(role, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Logic.SYM_LOGIC_ALL, Cons.cons(role, Cons.cons(Cons.cons(argument, Stella.NIL), Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL))))), Cons.consList(Cons.cons(implicitvariable, Stella.NIL))));
      }
      else if ((operator == Logic.SYM_LOGIC_FILLED_BY) ||
          (operator == Logic.SYM_LOGIC_FILLERS)) {
        { Cons clauses = Stella.NIL;
          Stella_Object translatedrole = Logic.loomArgumentDescriptionToKif(role, Logic.KWD_BINARY);

          { Stella_Object filler = null;
            Cons iter001 = tree.rest.rest;
            Cons collect000 = null;

            for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
              filler = iter001.value;
              if (collect000 == null) {
                {
                  collect000 = Cons.cons(Cons.cons(translatedrole, Cons.cons(implicitvariable, Cons.cons(filler, Stella.NIL))), Stella.NIL);
                  if (clauses == Stella.NIL) {
                    clauses = collect000;
                  }
                  else {
                    Cons.addConsToEndOfConsList(clauses, collect000);
                  }
                }
              }
              else {
                {
                  collect000.rest = Cons.cons(Cons.cons(translatedrole, Cons.cons(implicitvariable, Cons.cons(filler, Stella.NIL))), Stella.NIL);
                  collect000 = collect000.rest;
                }
              }
            }
          }
          return (((Cons)(Logic.conjoinSentences(clauses))));
        }
      }
      else if (operator == Logic.SYM_LOGIC_NOT_FILLED_BY) {
        { Cons clauses = Stella.NIL;
          Stella_Object translatedrole = Logic.loomArgumentDescriptionToKif(role, Logic.KWD_BINARY);

          { Stella_Object filler = null;
            Cons iter002 = tree.rest.rest;
            Cons collect001 = null;

            for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
              filler = iter002.value;
              if (collect001 == null) {
                {
                  collect001 = Cons.cons(Cons.list$(Cons.cons(Logic.SYM_STELLA_NOT, Cons.cons(Cons.cons(translatedrole, Cons.cons(implicitvariable, Cons.cons(filler, Stella.NIL))), Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL);
                  if (clauses == Stella.NIL) {
                    clauses = collect001;
                  }
                  else {
                    Cons.addConsToEndOfConsList(clauses, collect001);
                  }
                }
              }
              else {
                {
                  collect001.rest = Cons.cons(Cons.list$(Cons.cons(Logic.SYM_STELLA_NOT, Cons.cons(Cons.cons(translatedrole, Cons.cons(implicitvariable, Cons.cons(filler, Stella.NIL))), Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL);
                  collect001 = collect001.rest;
                }
              }
            }
          }
          return (((Cons)(Logic.conjoinSentences(clauses))));
        }
      }
      else {
        { OutputStringStream stream002 = OutputStringStream.newOutputStringStream();

          stream002.nativeStream.print("`" + operator + "' is not a valid case option");
          throw ((StellaException)(StellaException.newStellaException(stream002.theStringReader()).fillInStackTrace()));
        }
      }
    }
  }