public static boolean memberOfCollectionP(Stella_Object member, Stella_Object collection) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(collection);

      if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_NAMED_DESCRIPTION)) {
        { NamedDescription collection000 = ((NamedDescription)(collection));

          return (Logic.allTrueDependentPropositions(member, collection000.surrogateValueInverse, true).nextP());
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_COLLECTION)) {
        { Collection collection000 = ((Collection)(collection));

          { boolean foundP000 = false;

            { Stella_Object m = null;
              Iterator iter000 = ((Iterator)(collection000.allocateIterator()));

              loop000 : while (iter000.nextP()) {
                m = iter000.value;
                if (Stella_Object.eqlP(Logic.valueOf(m), member)) {
                  foundP000 = true;
                  break loop000;
                }
              }
            }
            { boolean memberP = foundP000;

              if (((Boolean)(Logic.$REVERSEPOLARITYp$.get())).booleanValue()) {
                return (!memberP);
              }
              else {
                return (memberP);
              }
            }
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_SKOLEM)) {
        { Skolem collection000 = ((Skolem)(collection));

          { boolean successP = false;
            Cons enumeratedcollections = Logic.allDefiningPropositions(collection000, Logic.SGT_PL_KERNEL_KB_COLLECTIONOF, true);

            if (!(enumeratedcollections == Stella.NIL)) {
              { Proposition col = null;
                Cons iter001 = enumeratedcollections;

                for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
                  col = ((Proposition)(iter001.value));
                  { Stella_Object arg = null;
                    Vector vector000 = col.arguments;
                    int index000 = 0;
                    int length000 = vector000.length();
                    int i = Stella.NULL_INTEGER;
                    int iter002 = 2;
                    int upperBound000 = col.arguments.length();

                    loop002 : for (;(index000 < length000) &&
                              (iter002 <= upperBound000); index000 = index000 + 1, iter002 = iter002 + 1) {
                      arg = (vector000.theArray)[index000];
                      i = iter002;
                      if (Stella_Object.eqlP(Logic.valueOf(arg), member)) {
                        i = i;
                        successP = true;
                        break loop002;
                      }
                    }
                  }
                }
              }
              if (((Boolean)(Logic.$REVERSEPOLARITYp$.get())).booleanValue()) {
                return (!successP);
              }
              else {
                return (successP);
              }
            }
            else {
              { Proposition p = null;
                Iterator iter003 = Logic.allTrueDependentPropositions(member, Logic.SGT_PL_KERNEL_KB_MEMBER_OF, false);

                while (iter003.nextP()) {
                  p = ((Proposition)(iter003.value));
                  { LogicObject subcollection = ((LogicObject)(Logic.valueOf((p.arguments.theArray)[1])));

                    if ((((Boolean)(Logic.$REVERSEPOLARITYp$.get())).booleanValue() ? LogicObject.collectionImpliesCollectionP(collection000, subcollection) : LogicObject.collectionImpliesCollectionP(subcollection, collection000))) {
                      return (true);
                    }
                  }
                }
              }
              return (false);
            }
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_LOGIC_OBJECT)) {
        { LogicObject collection000 = ((LogicObject)(collection));

          { Skolem equivalentskolem = ((Skolem)(((LogicObject)(collection000.variableValueInverse().value))));

            if (equivalentskolem != null) {
              return (Logic.memberOfCollectionP(member, equivalentskolem));
            }
          }
        }
      }
      else {
      }
    }
    {
      Stella.STANDARD_WARNING.nativeStream.println("Warning: member-of-collection?: Illegal collection type: `" + Surrogate.wrappedTypeToType(collection.primaryType()).symbolName + "'");
      Stella.STANDARD_WARNING.nativeStream.println("   member=`" + member + "' collection=`" + collection + "'");
      Stella.STANDARD_WARNING.nativeStream.println();
    }
;
    return (false);
  }