#NEWLINE# def is_tautology( self ) : #NEWLINE# #INDENT# '\n        Self is a tautology if it contains ground terms P and -P.  The ground\n        term, P, must be an exact match, ie, not using unification.\n        ' #NEWLINE# if ( self . _is_tautology is not None ) : #NEWLINE# #INDENT# return self . _is_tautology #NEWLINE# #UNINDENT# for ( i , a ) in enumerate ( self ) : #NEWLINE# #INDENT# if ( not isinstance ( a , EqualityExpression ) ) : #NEWLINE# #INDENT# j = ( len ( self ) - 1 ) #NEWLINE# while ( j > i ) : #NEWLINE# #INDENT# b = self [ j ] #NEWLINE# if isinstance ( a , NegatedExpression ) : #NEWLINE# #INDENT# if ( a . term == b ) : #NEWLINE# #INDENT# self . _is_tautology = True #NEWLINE# return True #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( j , NegatedExpression ) : #NEWLINE# #INDENT# if ( a == b . term ) : #NEWLINE# #INDENT# self . _is_tautology = True #NEWLINE# return True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# j -= 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . _is_tautology = False #NEWLINE# return False