def regexHasSubstringWitness(regex):
  """Returns True if regex has a Subtring Witness among its witnesses

  Substring witness: An input where
    - two languages agree on a match, but
    - disagree on the matching substring
  """
  # Check if any of the SDWs disagreed about the contents of a match
  for sdw in regex.semanticDifferenceWitnesses:
    # Did any two sets of languages find different substrings to match?
    uniqueMatchingSubstrings = set([
      mr.matchContents.matchedString
      for mr in sdw.matchResultToLangs
      if mr.matched
    ])
    if len(uniqueMatchingSubstrings) > 1:
      #libLF.log("Substring witness: {}".format(sdw.toNDJSON()))
      #libLF.log("  Unique matching substrings: {}".format(uniqueMatchingSubstrings))
      return True
  return False