public static void destroyLogicInstance(Stella_Object self) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(self);

      if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_LOGIC_OBJECT)) {
        { LogicObject self000 = ((LogicObject)(self));

          if ((self000 == null) ||
              self000.deletedP()) {
            return;
          }
          self000.deletedPSetter(true);
          { Surrogate surrogate = self000.surrogateValueInverse;

            if ((surrogate != null) &&
                (surrogate.surrogateValue == self000)) {
              surrogate.surrogateValue = null;
            }
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_THING)) {
        { Thing self000 = ((Thing)(self));

          if ((self000 == null) ||
              self000.deletedP()) {
            return;
          }
          self000.deletedPSetter(true);
          { Surrogate surrogate = self000.surrogateValueInverse;

            if ((surrogate != null) &&
                (surrogate.surrogateValue == self000)) {
              surrogate.surrogateValue = null;
            }
          }
        }
      }
      else {
        { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

          stream000.nativeStream.print("`" + testValue000 + "' is not a valid case option");
          throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
        }
      }
    }
    { Proposition p = null;
      Iterator iter000 = Logic.unfilteredDependentPropositions(self, null).allocateIterator();

      while (iter000.nextP()) {
        p = ((Proposition)(iter000.value));
        Proposition.destroyProposition(p);
      }
    }
    if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(self), Logic.SGT_LOGIC_LOGIC_OBJECT)) {
      { LogicObject self000 = ((LogicObject)(self));

        LogicObject.unlinkEquivalentValue(self000);
        { LogicObject equivalent = null;
          Cons iter001 = self000.variableValueInverse();

          for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
            equivalent = ((LogicObject)(iter001.value));
            if (!equivalent.deletedP()) {
              { Surrogate testValue001 = Stella_Object.safePrimaryType(equivalent);

                if (Surrogate.subtypeOfP(testValue001, Logic.SGT_LOGIC_SKOLEM)) {
                  { Skolem equivalent000 = ((Skolem)(equivalent));

                    { Skolem object000 = equivalent000;
                      Stella_Object value000 = null;
                      Stella_Object oldValue000 = object000.variableValue;
                      Stella_Object newValue000 = Stella_Object.updateInContext(oldValue000, value000, object000.homeContext, false);

                      if (!((oldValue000 != null) &&
                          (oldValue000.primaryType() == Logic.SGT_STELLA_CS_VALUE))) {
                        object000.variableValue = newValue000;
                      }
                    }
                  }
                }
                else if (Surrogate.subtypeOfP(testValue001, Logic.SGT_LOGIC_LOGIC_OBJECT)) {
                  { LogicObject equivalent000 = ((LogicObject)(equivalent));

                    { LogicObject object001 = equivalent000;
                      Description value001 = null;
                      Stella_Object oldValue001 = KeyValueList.dynamicSlotValue(object001.dynamicSlots, Logic.SYM_LOGIC_EQUIVALENT_VALUE, null);
                      Stella_Object newValue001 = Stella_Object.updateInContext(oldValue001, value001, object001.homeContext, false);

                      if (!((oldValue001 != null) &&
                          (oldValue001.primaryType() == Logic.SGT_STELLA_CS_VALUE))) {
                        KeyValueList.setDynamicSlotValue(object001.dynamicSlots, Logic.SYM_LOGIC_EQUIVALENT_VALUE, newValue001, null);
                      }
                    }
                  }
                }
                else {
                  { OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

                    stream001.nativeStream.print("`" + testValue001 + "' is not a valid case option");
                    throw ((StellaException)(StellaException.newStellaException(stream001.theStringReader()).fillInStackTrace()));
                  }
                }
              }
            }
          }
        }
        { LogicObject object002 = self000;
          Cons value002 = null;
          Stella_Object oldValue002 = object002.variableValueInverse;
          Stella_Object newValue002 = Stella_Object.updateInContext(oldValue002, value002, object002.homeContext, false);

          if (!((oldValue002 != null) &&
              (oldValue002.primaryType() == Logic.SGT_STELLA_CS_VALUE))) {
            object002.variableValueInverse = newValue002;
          }
        }
      }
    }
    else {
    }
  }