public static int computeLoomDescriptionArity(Stella_Object tree) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(tree);

      if (Surrogate.subtypeOfSymbolP(testValue000)) {
        { Symbol tree000 = ((Symbol)(tree));

          { NamedDescription description = Logic.getDescription(tree000);

            if (description != null) {
              return (description.arity());
            }
          }
        }
      }
      else if (testValue000 == Logic.SGT_STELLA_CONS) {
        { Cons tree000 = ((Cons)(tree));

          { GeneralizedSymbol testValue001 = ((GeneralizedSymbol)(tree000.value));

            if ((testValue001 == Logic.SYM_STELLA_AND) ||
                (testValue001 == Logic.SYM_STELLA_OR)) {
              { Stella_Object arg = null;
                Cons iter000 = tree000.rest;

                for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
                  arg = iter000.value;
                  { int guess = Logic.computeLoomDescriptionArity(arg);

                    if (guess > 0) {
                      return (guess);
                    }
                  }
                }
              }
            }
            else if ((testValue001 == Logic.SYM_LOGIC_AT_LEAST) ||
                ((testValue001 == Logic.SYM_LOGIC_AT_MOST) ||
                 ((testValue001 == Logic.SYM_LOGIC_ALL) ||
                  (testValue001 == Logic.SYM_LOGIC_SAME_AS)))) {
              return (1);
            }
            else if ((testValue001 == Logic.SYM_LOGIC_DOMAIN) ||
                ((testValue001 == Logic.SYM_LOGIC_RANGE) ||
                 ((testValue001 == Logic.SYM_STELLA_INVERSE) ||
                  ((testValue001 == Logic.SYM_PL_KERNEL_KB_INVERSE) ||
                   (testValue001 == Logic.SYM_LOGIC_COMPOSE))))) {
              return (2);
            }
            else if ((testValue001 == Logic.SYM_STELLA_g) ||
                ((testValue001 == Logic.SYM_STELLA_l) ||
                 ((testValue001 == Logic.SYM_STELLA_ge) ||
                  ((testValue001 == Logic.SYM_STELLA_le) ||
                   ((testValue001 == Logic.SYM_LOGIC_lg) ||
                    (testValue001 == Logic.SYM_STELLA_e)))))) {
              return (tree000.rest.length());
            }
            else if (testValue001 == Logic.SYM_LOGIC_RELATES) {
              return (tree000.rest.rest.length());
            }
            else if (testValue001 == Logic.SYM_LOGIC_SATISFIES) {
              { Stella_Object variables = tree000.rest.value;

                if (Stella_Object.consP(variables)) {
                  return (((Cons)(variables)).length());
                }
                else {
                  return (1);
                }
              }
            }
            else {
            }
          }
        }
      }
      else {
      }
    }
    return (-1);
  }