<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_value_string (f, value_string):
 """ Checks that value-string is a valid value-string for the given feature. """

    assert isinstance(f, Feature)
    assert isinstance(value_string, basestring)
    if f.free or value_string in f.values:
        return

    values = [value_string]

    if f.subfeatures:
        if not value_string in f.values and \
               not value_string in f.subfeatures:
            values = value_string.split('-')

    # An empty value is allowed for optional features
    if not values[0] in f.values and \
           (values[0] or not f.optional):
        raise InvalidValue ("'%s' is not a known value of feature '%s'\nlegal values: '%s'" % (values [0], f.name, f.values))

    for v in values [1:]:
        # this will validate any subfeature values in value-string
        implied_subfeature(f, v, values[0])