public static boolean helpClosedTermP(Stella_Object self, Cons activeterms) {
    if (self == null) {
      return (false);
    }
    if (activeterms.membP(self)) {
      return (false);
    }
    else {
      activeterms = Cons.cons(self, activeterms);
    }
    { Surrogate testValue000 = Stella_Object.safePrimaryType(self);

      if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_NAMED_DESCRIPTION)) {
        { NamedDescription self000 = ((NamedDescription)(self));

          return ((Logic.testPropertyP(self000, Logic.SGT_PL_KERNEL_KB_CLOSED) &&
              (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(((Context)(Stella.$CONTEXT$.get())).dynamicSlots, Logic.SYM_LOGIC_MONOTONICp, Stella.FALSE_WRAPPER))).wrapperValue)) ||
              ((((Description)(Stella_Object.accessInContext(KeyValueList.dynamicSlotValue(self000.dynamicSlots, Logic.SYM_LOGIC_EQUIVALENT_VALUE, null), self000.homeContext, false))) != null) &&
               Logic.helpClosedTermP(((Description)(Stella_Object.accessInContext(KeyValueList.dynamicSlotValue(self000.dynamicSlots, Logic.SYM_LOGIC_EQUIVALENT_VALUE, null), self000.homeContext, false))), activeterms)));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_DESCRIPTION)) {
        { Description self000 = ((Description)(self));

          return ((Logic.testPropertyP(self000, Logic.SGT_PL_KERNEL_KB_CLOSED) &&
              (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(((Context)(Stella.$CONTEXT$.get())).dynamicSlots, Logic.SYM_LOGIC_MONOTONICp, Stella.FALSE_WRAPPER))).wrapperValue)) ||
              Proposition.helpClosedPropositionP(self000.proposition, activeterms));
        }
      }
      else if (Surrogate.subtypeOfSurrogateP(testValue000)) {
        { Surrogate self000 = ((Surrogate)(self));

          return (Logic.helpClosedTermP(Logic.valueOf(self000), activeterms));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PATTERN_VARIABLE)) {
        { PatternVariable self000 = ((PatternVariable)(self));

          return (false);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_SKOLEM)) {
        { Skolem self000 = ((Skolem)(self));

          { Proposition definingprop = self000.definingProposition;

            return (((definingprop != null) &&
                Proposition.collectionofPropositionP(definingprop)) ||
                (Logic.testPropertyP(self000, Logic.SGT_PL_KERNEL_KB_CLOSED) &&
                 (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(((Context)(Stella.$CONTEXT$.get())).dynamicSlots, Logic.SYM_LOGIC_MONOTONICp, Stella.FALSE_WRAPPER))).wrapperValue)));
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_LOGIC_OBJECT)) {
        { LogicObject self000 = ((LogicObject)(self));

          return (Logic.testPropertyP(self000, Logic.SGT_PL_KERNEL_KB_CLOSED) &&
              (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(((Context)(Stella.$CONTEXT$.get())).dynamicSlots, Logic.SYM_LOGIC_MONOTONICp, Stella.FALSE_WRAPPER))).wrapperValue));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_THING)) {
        { Thing self000 = ((Thing)(self));

          return (Logic.testPropertyP(self000, Logic.SGT_PL_KERNEL_KB_CLOSED) &&
              (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(((Context)(Stella.$CONTEXT$.get())).dynamicSlots, Logic.SYM_LOGIC_MONOTONICp, Stella.FALSE_WRAPPER))).wrapperValue));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_COLLECTION)) {
        { Collection self000 = ((Collection)(self));

          return (true);
        }
      }
      else {
        return (false);
      }
    }
  }