code: def check_negated_goals(self,safe_variables,query):
          ''' Create a list of variables which occur in negated goals. '''
          variables_in_negated_goals = \
              [y for x in query.relations for y in list(x.variables) if x.is_negated()]
  
          # And check them:
          for variable in variables_in_negated_goals:
              if not (variable in safe_variables):
                  raise NotSafeException('Query not safe because ' + \
                      variable.name + \
                      ' from a negated goal does not occur in a positive goal')
                  return False
  
          return Truf check_negated_goals(self,safe_variables,query):
          ''' Create a list of variables which occur in negated goals. '''
          variables_in_negated_goals = \
              [y for x in query.relations for y in list(x.variables) if x.is_negated()]
  
          # And check them:
          for variable in variables_in_negated_goals:
              if not (variable in safe_variables):
                  raise NotSafeException('Query not safe because ' + \
                      variable.name + \
                      ' from a negated goal does not occur in a positive goal')
                  return False
  
          return True
docs: Create a list of variables which occur in negated goals.