public static boolean argumentMatchesListHelperP(Stella_Object argument, List theList) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(argument);

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

          { Stella_Object value = (((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord.variableBindings.theArray)[(argument000.boundToOffset)];

            if (value != null) {
              return (Units.argumentMatchesListHelperP(value, theList));
            }
            else {
              return (true);
            }
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Units.SGT_LOGIC_SKOLEM)) {
        { Skolem argument000 = ((Skolem)(argument));

          { Proposition prop = argument000.definingProposition;
            Vector args = ((prop != null) ? prop.arguments : ((Vector)(null)));
            int listLength = theList.length();

            if (args == null) {
              return (false);
            }
            else if (args.length() == (listLength + 1)) {
              { Stella_Object item = null;
                Cons iter000 = theList.theConsList;
                int i = Stella.NULL_INTEGER;
                int iter001 = 0;

                for (;!(iter000 == Stella.NIL); iter000 = iter000.rest, iter001 = iter001 + 1) {
                  item = iter000.value;
                  i = iter001;
                  if (!(Stella_Object.eqlP(item, (args.theArray)[i]))) {
                    return (false);
                  }
                }
              }
              return (true);
            }
            else {
              return (false);
            }
          }
        }
      }
      else {
        return (false);
      }
    }
  }