public static Stella_Object evaluateFirstArgument(Stella_Object argument, Symbol relationname) {
    { LogicObject predicatevalue = Logic.evaluatePredicate(relationname, null);
      Surrogate type = null;
      Stella_Object firstargument = null;

      if ((predicatevalue != null) &&
          Stella_Object.isaP(predicatevalue, Logic.SGT_LOGIC_NAMED_DESCRIPTION)) {
        type = ((Surrogate)(((NamedDescription)(predicatevalue)).ioVariableTypes.first()));
      }
      firstargument = Logic.evaluateTypedArgument(argument, type);
      if ((relationname == Logic.SYM_PL_KERNEL_KB_VALUE) ||
          (relationname == Logic.SYM_PL_KERNEL_KB_HOLDS)) {
        if (Logic.descriptionModeP() &&
            Logic.variableP(firstargument)) {
          { Proposition fnprop = ((PatternVariable)(firstargument)).definingProposition;

            { boolean testValue000 = false;

              testValue000 = fnprop != null;
              if (testValue000) {
                { boolean foundP000 = false;

                  { int i = Stella.NULL_INTEGER;
                    int iter000 = 0;
                    int upperBound000 = fnprop.arguments.length() - 2;

                    loop000 : for (;iter000 <= upperBound000; iter000 = iter000 + 1) {
                      i = iter000;
                      if (Logic.variableP((fnprop.arguments.theArray)[i])) {
                        foundP000 = true;
                        break loop000;
                      }
                    }
                  }
                  testValue000 = foundP000;
                }
                testValue000 = !testValue000;
              }
              if (testValue000) {
                { Object old$Evaluationmode$000 = Logic.$EVALUATIONMODE$.get();

                  try {
                    Native.setSpecial(Logic.$EVALUATIONMODE$, Logic.KWD_EXTENSIONAL_ASSERTION);
                    firstargument = Logic.evaluateTypedArgument(argument, type);

                  } finally {
                    Logic.$EVALUATIONMODE$.set(old$Evaluationmode$000);
                  }
                }
              }
            }
          }
        }
      }
      else {
      }
      if (firstargument == null) {
        Logic.signalUndefinedTerm(argument);
      }
      { Object old$SuppressnonlogicobjectwarningP$000 = Logic.$SUPPRESSNONLOGICOBJECTWARNINGp$.get();

        try {
          Native.setBooleanSpecial(Logic.$SUPPRESSNONLOGICOBJECTWARNINGp$, true);
          if (Logic.valueOf(firstargument) == Logic.BOTTOM) {
            Logic.signalUndefinedTerm(firstargument);
          }

        } finally {
          Logic.$SUPPRESSNONLOGICOBJECTWARNINGp$.set(old$SuppressnonlogicobjectwarningP$000);
        }
      }
      return (firstargument);
    }
  }