def truth_table(expr, variables, input=True):
 variables = [sympify(v) for v in variables]
 expr = sympify(expr)
 if ((not isinstance(expr, BooleanFunction)) and (not is_literal(expr))):
  return
 table = product([0, 1], repeat=len(variables))
 for term in table:
  term = list(term)
  value = expr.xreplace(dict(zip(variables, term)))
  if input:
   (yield (term, value))
  else:
   (yield value)

def truth_table ( expr , variables , input = True ) : variables = [ sympify ( v ) for v in variables ] expr = sympify ( expr ) if ( ( not isinstance ( expr , BooleanFunction ) ) and ( not is_literal ( expr ) ) ) : return table = product ( [ 0 , 1 ] , repeat = len ( variables ) ) for term in table : term = list ( term ) value = expr . xreplace ( dict ( zip ( variables , term ) ) ) if input : ( yield ( term , value ) ) else : ( yield value )
return a generator of all possible configurations of the input variables .