public static Surrogate computeRelationTermSurrogate(Skolem skolem, Proposition proposition) {
    { Proposition functionprop = skolem.definingProposition;
      String string = Native.stringify(Proposition.generateFunctionAsTerm(functionprop));
      Surrogate surrogate = null;
      int arity = 0;
      List argumentnames = null;
      List argumenttypes = null;
      NamedDescription description = null;

      surrogate = GeneralizedSymbol.internDerivedSurrogate(((Surrogate)(functionprop.operator)), string);
      if (surrogate.surrogateValue != null) {
        return (surrogate);
      }
      if (Logic.testPropertyP(skolem, Logic.SGT_PL_KERNEL_KB_VARIABLE_ARITY)) {
        arity = -1;
      }
      else if (Logic.accessBinaryValue(skolem, Logic.SGT_PL_KERNEL_KB_ARITY) != null) {
        arity = ((IntegerWrapper)(Logic.accessBinaryValue(skolem, Logic.SGT_PL_KERNEL_KB_ARITY))).wrapperValue;
      }
      else {
        arity = proposition.arguments.length() - 1;
      }
      if (arity == -1) {
        argumentnames = List.list(Cons.cons(Logic.yieldSystemDefinedParameterName(1, skolem), Stella.NIL));
        argumenttypes = List.list(Cons.cons(Logic.SGT_STELLA_THING, Stella.NIL));
      }
      else {
        argumentnames = List.newList();
        argumenttypes = List.newList();
        { int i = Stella.NULL_INTEGER;
          int iter000 = 0;
          int upperBound000 = arity - 1;

          for (;iter000 <= upperBound000; iter000 = iter000 + 1) {
            i = iter000;
            argumentnames.insert(Logic.yieldSystemDefinedParameterName(i, skolem));
            argumenttypes.insert(Logic.SGT_STELLA_THING);
          }
        }
        argumentnames.reverse();
        argumenttypes.reverse();
      }
      description = Logic.createPrimitiveDescription(argumentnames, argumenttypes, arity < 0, (Logic.logicalType(skolem) == Logic.SGT_PL_KERNEL_KB_CLASS) ||
          Logic.classP(skolem), (Logic.logicalType(skolem) == Logic.SGT_PL_KERNEL_KB_FUNCTION) ||
          ((proposition.operator == Logic.SGT_PL_KERNEL_KB_VALUE) ||
           Logic.functionP(skolem)), ((Module)(surrogate.homeContext)));
      surrogate.surrogateValue = description;
      description.surrogateValueInverse = surrogate;
      Description.ensureDescriptionBody(description);
      return (surrogate);
    }
  }