def _check_cg(cg_term, expr, length, sign=None):
 matches = cg_term.match(expr)
 if (matches is None):
  return
 if (sign is not None):
  if (not isinstance(sign, tuple)):
   raise TypeError('sign must be a tuple')
  if (not (sign[0] == sign[1].subs(matches))):
   return
 if (len(matches) == length):
  return matches

def _check_cg ( cg_term , expr , length , sign = None ) : matches = cg_term . match ( expr ) if ( matches is None ) : return if ( sign is not None ) : if ( not isinstance ( sign , tuple ) ) : raise TypeError ( 'sign must be a tuple' ) if ( not ( sign [ 0 ] == sign [ 1 ] . subs ( matches ) ) ) : return if ( len ( matches ) == length ) : return matches
checks whether a term matches the given expression .