def deduce_alpha_implications(implications):
 implications = (implications + [(Not(j), Not(i)) for (i, j) in implications])
 res = defaultdict(set)
 full_implications = transitive_closure(implications)
 for (a, b) in full_implications:
  if (a == b):
   continue
  res[a].add(b)
 for (a, impl) in res.items():
  impl.discard(a)
  na = Not(a)
  if (na in impl):
   raise ValueError(('implications are inconsistent: %s -> %s %s' % (a, na, impl)))
 return res

def deduce_alpha_implications ( implications ) : implications = ( implications + [ ( Not ( j ) , Not ( i ) ) for ( i , j ) in implications ] ) res = defaultdict ( set ) full_implications = transitive_closure ( implications ) for ( a , b ) in full_implications : if ( a == b ) : continue res [ a ] . add ( b ) for ( a , impl ) in res . items ( ) : impl . discard ( a ) na = Not ( a ) if ( na in impl ) : raise ValueError ( ( 'implications are inconsistent: %s -> %s %s' % ( a , na , impl ) ) ) return res
deduce all implications description by example given set of logic rules: a -> b b -> c we deduce all possible rules: a -> b .