public static Surrogate evaluateRelationTerm(Stella_Object relationterm, Proposition proposition) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(relationterm);

      if (Surrogate.subtypeOfSurrogateP(testValue000)) {
        { Surrogate relationterm000 = ((Surrogate)(relationterm));

          return (relationterm000);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PATTERN_VARIABLE)) {
        { PatternVariable relationterm000 = ((PatternVariable)(relationterm));

          return (null);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_SKOLEM)) {
        { Skolem relationterm000 = ((Skolem)(relationterm));

          if (!Logic.functionOutputSkolemP(relationterm000)) {
            return (null);
          }
          { Vector arguments = relationterm000.definingProposition.arguments;
            Surrogate relationtermsurrogate = null;
            Stella_Object relationtermvalue = Logic.valueOf(relationterm000);

            { boolean foundP000 = false;

              { Stella_Object arg = null;
                Vector vector000 = arguments;
                int index000 = 0;
                int length000 = vector000.length();

                loop000 : for (;index000 < length000; index000 = index000 + 1) {
                  arg = (vector000.theArray)[index000];
                  if (Stella_Object.isaP(arg, Logic.SGT_LOGIC_PATTERN_VARIABLE)) {
                    foundP000 = true;
                    break loop000;
                  }
                }
              }
              if (foundP000) {
                return (null);
              }
            }
            if (!(relationtermvalue == relationterm000)) {
              return (Logic.evaluateRelationTerm(relationtermvalue, proposition));
            }
            relationtermsurrogate = Skolem.computeRelationTermSurrogate(relationterm000, proposition);
            Logic.transferPropositionsAndBacklinks(relationterm000, Logic.valueOf(relationtermsurrogate));
            (arguments.theArray)[(arguments.length() - 1)] = relationtermsurrogate;
            return (relationtermsurrogate);
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_NAMED_DESCRIPTION)) {
        { NamedDescription relationterm000 = ((NamedDescription)(relationterm));

          return (relationterm000.surrogateValueInverse);
        }
      }
      else {
        return (null);
      }
    }
  }