public static boolean bindArgumentToValueP(Stella_Object argument, Stella_Object value, boolean autocleanupP) {
    if (value == null) {
      if (((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
          (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) &&
          ((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy.allowUnboundVariablesP()) {
        return (true);
      }
      { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get();

        try {
          Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
          Stella.STANDARD_WARNING.nativeStream.println("WARNING: Tried to bind " + argument + " to NULL value.  Potentially a PowerLoom bug");
          Logic.helpSignalPropositionError(Stella.STANDARD_WARNING, Logic.KWD_WARNING);

        } finally {
          Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
        }
      }
      return (false);
    }
    value = Logic.instantiateExternalBindings(value);
    { Surrogate testValue000 = Stella_Object.safePrimaryType(argument);

      if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PATTERN_VARIABLE)) {
        { PatternVariable argument000 = ((PatternVariable)(argument));

          return (PatternVariable.bindVariableToValueP(argument000, value, autocleanupP));
        }
      }
      else if (Surrogate.subtypeOfSurrogateP(testValue000)) {
        { Surrogate argument000 = ((Surrogate)(argument));

          return (Stella_Object.eqlP(Logic.valueOf(argument000), value));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PROPOSITION)) {
        { Proposition argument000 = ((Proposition)(argument));

          if (Stella_Object.isaP(value, Logic.SGT_LOGIC_PROPOSITION)) {
            { KeyValueMap mapping = KeyValueMap.newKeyValueMap();

              { boolean testValue001 = false;

                testValue001 = Proposition.unifyPropositionsP(argument000, ((Proposition)(value)), mapping);
                if (testValue001) {
                  { boolean alwaysP000 = true;

                    { Stella_Object var = null;
                      Stella_Object val = null;
                      DictionaryIterator iter000 = ((DictionaryIterator)(mapping.allocateIterator()));

                      loop000 : while (iter000.nextP()) {
                        var = iter000.key;
                        val = iter000.value;
                        if (!PatternVariable.bindVariableToValueP(((PatternVariable)(var)), val, autocleanupP)) {
                          alwaysP000 = false;
                          break loop000;
                        }
                      }
                    }
                    testValue001 = alwaysP000;
                  }
                }
                if (testValue001) {
                  return (true);
                }
              }
            }
          }
          return (false);
        }
      }
      else {
        return (Stella_Object.eqlP(argument, value));
      }
    }
  }