def __init__ (self, name): self.p9_file_name = '' self.tptp_file_name = '' name = filemgt.get_canonical_relative_path(name) self.module = ClifModule(name,0) logging.getLogger(__name__).debug('constructed clif module for lemma file: ' + self.module.module_name) self.module.get_p9_file_name() self.lemmas = [] self.add_lemmas()
def get_imports(input_file): """Find all the imported modules from a CLIF single_file. Parameters: input_file -- filename of the CLIF input.""" imports = set([]) sentences = get_sentences_from_file(input_file) for s in sentences: if len(s) == 2 and s[0] == CLIF_IMPORT: imports.add(filemgt.get_canonical_relative_path(s[1])) # print "IMPORTS = " + str(imports) return imports
def set_module_name(self, name): self.module_name = filemgt.get_canonical_relative_path(name)
def __init__(self, name): #filemgt.start_logging() name = filemgt.get_canonical_relative_path(name) # keep track of when all imports have been processed; necessary for detecting nonlogical symbols in the import structure self.completely_processed = False logging.getLogger(__name__).info("Creating ClifModuleSet " + name) self.module_name = '' # list of ClifModules that are imported and have been processed already self.imports = set([]) # keeps track of the lemma that needs to be proved; this is None if no lemma needs to be proved self.lemma_module = None # list of imports that still require processing self.unprocessed_imports = set([]) # list of nonlogical symbols that occur in any imported files # it is a tuple [symbol, count, d_min, d_max] where # symbol: name of the symbol # count: total number of Occurrences # d_min: minimal depth in the CL-import tree where it occurs # d_max: maximal depth in the CL-import tree where it occurs self.nonlogical_symbols = set([]) self.defined_nonlogical_symbols = set([]) # the primitive and potentially some defined predicates occurring in any imported files self.primitive_predicates = set([]) # a list of predicates that are definitively defined predicates occurring in any imported files self.defined_predicates = set([]) # the functions occurring in any imported files self.nonskolem_functions = set([]) self.p9_file_name = '' self.tptp_file_name = '' m = ClifModule(name, depth=0) m.module_set = self self.imports.add(m) self.module_name = m.module_name self.unprocessed_imports = self.unprocessed_imports.union( m.get_imports()) while len(self.unprocessed_imports) > 0: # Process the next import that has not yet been processed m = ClifModule(self.unprocessed_imports.pop()) m.module_set = self # # Link the module to all its parents: DOES NOT WORK CORRECTLY; we need to do this at the very end! # for cm in self.imports: # look through the complete set of imported modules # if m.module_name in cm.get_imports(): # each module cm that imports the currently processed module m will be added as parent to m # m.add_parent(cm.module_name,cm.get_depth()) # add as parent to the module self.imports.add(m) # add all the names of imported modules that have not yet been processed new_imports = set(m.get_imports()) - set( [i.module_name for i in self.imports]) - set(self.unprocessed_imports) for i in new_imports: logging.getLogger(__name__).info('|-- imports: ' + i + ' (depth ' + str(m.get_depth() + 1) + ')') self.unprocessed_imports = self.unprocessed_imports.union( new_imports) self.completely_processed = True self.pretty_print()