예제 #1
0
    def preprocess_clif_file(self):
        # add the standard ending for CLIF files to the module name
        self.clif_file_name = filemgt.get_full_path(self.module_name,
                                                    ending=filemgt.read_config(
                                                        'cl', 'ending'))
        #print self.clif_file_name

        self.clif_processed_file_name = filemgt.get_full_path(
            self.module_name,
            folder=filemgt.read_config('converters', 'tempfolder'),
            ending=filemgt.read_config('cl', 'ending'))

        logging.getLogger(__name__).debug("Clif file name = " +
                                          self.clif_file_name)
        logging.getLogger(__name__).debug("Clif preprocessed file name = " +
                                          self.clif_processed_file_name)

        clif.remove_all_comments(self.clif_file_name,
                                 self.clif_processed_file_name)

        self.imports = clif.get_imports(self.clif_processed_file_name)

        logging.getLogger(__name__).debug("imports detected in " +
                                          self.module_name + ": " +
                                          str(self.imports))

        self.nonlogical_symbols = clif.get_all_nonlogical_symbols(
            self.clif_processed_file_name)
예제 #2
0
 def select_systems (self, outfile_stem):
     """read the activated provers and model finders from the configuration single_file
     return values:
     provers_dict -- a dictionary of all provers to be used with commands as keys and a set of return values as value
     finders_dict -- a dictionary of all model finders to be used with commands as keys and a set of return values as value
     """
     provers_dict = {}
     finders_dict = {}
     
     provers = filemgt.read_config('active','provers').split(',')
     finders = filemgt.read_config('active','modelfinders').split(',')
     
     provers = [ s.strip() for s in provers ]
     finders = [ s.strip() for s in finders ]
     
     for prover in provers:
         codes = self.get_posititve_returncodes(prover)
         cmd = ladr.get_system_command(prover, self.imports, outfile_stem)
         provers_dict[cmd] = codes
         self.provers[prover] = cmd
     for finder in finders:
         codes = self.get_posititve_returncodes(finder)
         cmd = ladr.get_system_command(finder, self.imports, outfile_stem)
         finders_dict[cmd] = codes
         self.finders[finder] = cmd
     
     return (provers_dict, finders_dict)
예제 #3
0
파일: ClifModule.py 프로젝트: KitN/macleod
 def get_p9_file_name (self):
     """get the filename of the LADR translation of the module and translate the ClifModule if not yet done so."""
     if not self.p9_file_name: # do the translation
         self.p9_file_name = filemgt.get_full_path(self.module_name,
                                                    folder=filemgt.read_config('ladr','folder'),
                                                    ending=filemgt.read_config('ladr','ending'))
         self.get_translated_file(self.p9_file_name, "LADR")
         logging.getLogger(__name__).info("CREATED LADR TRANSLATION: " + self.p9_file_name)
     return self.p9_file_name
예제 #4
0
 def get_p9_file_name(self):
     """get the filename of the LADR translation of the module and translate the ClifModule if not yet done so."""
     if not self.p9_file_name:  # do the translation
         self.p9_file_name = filemgt.get_full_path(
             self.module_name,
             folder=filemgt.read_config('ladr', 'folder'),
             ending=filemgt.read_config('ladr', 'ending'))
         self.get_translated_file(self.p9_file_name, "LADR")
         logging.getLogger(__name__).info("CREATED LADR TRANSLATION: " +
                                          self.p9_file_name)
     return self.p9_file_name
예제 #5
0
파일: ClifModule.py 프로젝트: KitN/macleod
 def get_tptp_file_name (self):
     """get the filename of the TPTP translation of the module and translate the ClifModule if not yet done so.
     This version does not rely on the clif to ladr translation, but does a direct translation."""
     
     if not self.tptp_file_name:
         self.tptp_file_name = filemgt.get_full_path(self.module_name,
                                                    folder=filemgt.read_config('tptp','folder'),
                                                    ending=filemgt.read_config('tptp','ending'))
                      
         self.get_translated_file(self.tptp_file_name, "TPTP")
         logging.getLogger(__name__).info("CREATED TPTP TRANSLATION: " + self.tptp_file_name)
     return self.tptp_file_name
예제 #6
0
    def get_single_tptp_file (self, number=0):
        
        single_p9_file = ladr.get_single_p9_file(get_module_name)
        ending = ''
        if not number==0:
            ending = '_' + str(number)

        self.tptp_file_name = filemgt.get_name_with_subfolder(self.imports[0].module_name,
                                                              filemgt.read_config('tptp','folder'),
                                                              ending + filemgt.read_config('tptp','all_ending'))
        
        TPTP.ladr_to_tptp(self.p9_file_name, self.tptp_file_name)
예제 #7
0
파일: ClifModule.py 프로젝트: Fxhnd/macleod
    def __init__(self,name,depth=None):

        """ Quick tree test ROB """
        self.width = 10 
        self.x = 50 
        self.y = 0
        """ End of ROB's stuff """

        '''
        Constructor
        '''
        self.module_set = None
        
        self.module_name = ''
        
        self.hierarchy_name = ''
        
        """set of all imported module names """
        self.imports = set([])
        
        """ set of all parent module names"""
        self.parents = None
        self.ancestors = None
        
        self.clif_file_name = ''
        
        """Location of the clif input file that has undergone preprocessing"""
        self.clif_processed_file_name = ''
        
        self.p9_file_name = None
        
        self.tptp_file_name = None
        
        # the distinction between nonlogical_symbols and nonlogical_variables assumes that a single symbol is not used as both in different sentences
        self.nonlogical_symbols = set([])
        self.import_closure_nonlogical_symbols = None
        
        self.properly_defined_symbols = None
        #self.parents_nonlogical_symbols = set([])
        
        # stores the depth of the import hierarchy
        self.depth = depth
        
        self.set_module_name(name)
        logging.getLogger(__name__).info('processing module: ' + self.module_name)
        # remove any obsolete URL ending as specified in the configuration file
        if self.module_name.endswith(filemgt.read_config('cl','ending')):
            self.module_name = os.path.normpath(self.module_name.replace(filemgt.read_config('cl','ending'),''))
            
        self.hierarchy_name = filemgt.get_hierarchy_name(self.module_name)
            
        self.preprocess_clif_file()
예제 #8
0
    def get_tptp_file_name(self):
        """get the filename of the TPTP translation of the module and translate the ClifModule if not yet done so.
        This version does not rely on the clif to ladr translation, but does a direct translation."""

        if not self.tptp_file_name:
            self.tptp_file_name = filemgt.get_full_path(
                self.module_name,
                folder=filemgt.read_config('tptp', 'folder'),
                ending=filemgt.read_config('tptp', 'ending'))

            self.get_translated_file(self.tptp_file_name, "TPTP")
            logging.getLogger(__name__).info("CREATED TPTP TRANSLATION: " +
                                             self.tptp_file_name)
        return self.tptp_file_name
예제 #9
0
    def __init__(self, name, depth=None):
        '''
        Constructor
        '''
        self.module_set = None

        self.module_name = ''

        self.hierarchy_name = ''
        """set of all imported module names """
        self.imports = set([])
        """ set of all parent module names"""
        self.parents = None
        self.ancestors = None

        self.clif_file_name = ''
        """Location of the clif input file that has undergone preprocessing"""
        self.clif_processed_file_name = ''

        self.p9_file_name = None

        self.tptp_file_name = None

        # the distinction between nonlogical_symbols and nonlogical_variables assumes that a single symbol is not used as both in different sentences
        self.nonlogical_symbols = set([])
        self.import_closure_nonlogical_symbols = None

        self.properly_defined_symbols = None
        #self.parents_nonlogical_symbols = set([])

        # stores the depth of the import hierarchy
        self.depth = depth

        self.set_module_name(name)
        logging.getLogger(__name__).info('processing module: ' +
                                         self.module_name)
        # remove any obsolete URL ending as specified in the configuration file
        if self.module_name.endswith(filemgt.read_config('cl', 'ending')):
            self.module_name = os.path.normpath(
                self.module_name.replace(filemgt.read_config('cl', 'ending'),
                                         ''))

        self.hierarchy_name = filemgt.get_hierarchy_name(self.module_name)

        self.preprocess_clif_file()
예제 #10
0
파일: ClifModule.py 프로젝트: KitN/macleod
    def preprocess_clif_file (self):
        # add the standard ending for CLIF files to the module name
        self.clif_file_name = filemgt.get_full_path(self.module_name, ending=filemgt.read_config('cl','ending'))
        #print self.clif_file_name

        self.clif_processed_file_name = filemgt.get_full_path(self.module_name,
                                                      folder= filemgt.read_config('converters','tempfolder'),
                                                      ending = filemgt.read_config('cl','ending'))

        logging.getLogger(__name__).debug("Clif file name = " + self.clif_file_name)
        logging.getLogger(__name__).debug("Clif preprocessed file name = " + self.clif_processed_file_name)
        
        clif.remove_all_comments(self.clif_file_name,self.clif_processed_file_name)
        
        
        self.imports = clif.get_imports(self.clif_processed_file_name)
        
        logging.getLogger(__name__).debug("imports detected in " + self.module_name + ": " + str(self.imports))
        
        self.nonlogical_symbols = clif.get_all_nonlogical_symbols(self.clif_processed_file_name)
예제 #11
0
    def run_consistency_check(self, options_files = None):
        """ test the input for consistency by trying to find a model or an inconsistency"""
        if self.run_prover:    
            # want to create a subfolder for the output files
            outfile_stem = filemgt.get_name_with_subfolder(self.imports[0].module_name, 
                                                            filemgt.read_config('output','folder')) 
            
            (provers, finders) = self.select_systems(outfile_stem)
            
            # run provers and modelfinders simultaneously and wait until one returns
            (prc, frc) = process.raceProcesses(provers, finders)

            print self.consolidate_results(provers, finders)
예제 #12
0
    def extract_p9_predicates_and_functions(self):

        #print 'extract predicates and functions'
        prover9args = 'prover9 -t 0 -f '

        for f in self.imports:
            prover9args += f.p9_file_name + ' '

        options_file = ladr.get_p9_optionsfile(self.get_module_name(),
                                               verbose=False)
        prover9args += ' ' + options_file + ' '

        # would be better to create a temporary single_file or read the output stream directly
        temp_file = self.get_module_name() + '_order' + filemgt.read_config(
            'ladr', 'ending')
        prover9args += ' > ' + temp_file
        print(prover9args)
        process.createSubprocess(prover9args)
        p9.wait()

        order_file = open(temp_file, 'r')
        line = order_file.readline()
        predicates = None
        functions = None
        while line:
            if line.find('predicate_order') > -1:
                predicateline = line[line.find('predicate_order([') +
                                     len('predicate_order([') + 1:-4]
                predicates = predicateline.split()
                for i in range(len(predicates)):
                    predicates[i] = predicates[i].replace(',', '')
                line = order_file.readline()
                functionline = line[line.find('function_order([') +
                                    len('function_order([') + 1:-4]
                functions = functionline.split()
                for i in range(len(functions)):
                    functions[i] = functions[i].replace(',', '')
                break
            line = order_file.readline()

        order_file.close()
        #print 'temp single_file : ' + temp_file
        #print 'options single_file : ' + options_file
        os.remove(temp_file)
        os.remove(options_file)
        if predicates and functions:
            return (predicates, functions)
        else:
            return ([], [])
예제 #13
0
    def extract_p9_predicates_and_functions (self):
    
        #print 'extract predicates and functions'
        prover9args = 'prover9 -t 0 -f '
        
    
        for f in self.imports:
            prover9args += f.p9_file_name + ' '
        
        options_file = ladr.get_p9_optionsfile(self.get_module_name(), verbose=False)
        prover9args += ' ' + options_file + ' '

        
        # would be better to create a temporary single_file or read the output stream directly
        temp_file = self.get_module_name() + '_order' + filemgt.read_config('ladr','ending')
        prover9args += ' > ' + temp_file
        print prover9args
        process.createSubprocess(prover9args)
        p9.wait()
        
        order_file = open(temp_file, 'r')
        line = order_file.readline()
        predicates = None
        functions = None
        while line:
            if line.find('predicate_order') > -1:
                predicateline = line[line.find('predicate_order([')+len('predicate_order([')+1:-4]
                predicates = predicateline.split()
                for i in range(len(predicates)):
                    predicates[i] = predicates[i].replace(',','')
                line = order_file.readline()
                functionline = line[line.find('function_order([')+len('function_order([')+1:-4]
                functions = functionline.split()
                for i in range(len(functions)):
                    functions[i] = functions[i].replace(',','')
                break
            line = order_file.readline()
            
        order_file.close()
        #print 'temp single_file : ' + temp_file
        #print 'options single_file : ' + options_file
        os.remove(temp_file)
        os.remove(options_file)
        if predicates and functions:
            return (predicates, functions)
        else:
            return ([], [])
예제 #14
0
    def add_lemmas (self):
        
        # first get LADR translation of ClifModule
        # logging.getLogger(__name__).debug("CREATING LADR TRANSLATION OF LEMMA: " + self.module.module_name)
        #self.module.get_p9_file_name()
        
        (lemma_names, ladr_files) = ladr.get_ladr_goal_files(self.module.get_p9_file_name(), self.module.module_name)
        logging.getLogger(__name__).debug("CREATED LADR TRANSLATION OF LEMMA: " + self.module.get_p9_file_name())

        # translate to tptp as goal
        tptp_sentences = clif.to_tptp([self.module.clif_processed_file_name], axiom=False)
        
#        for t in tptp_sentences:
#            print t

        # populate the list of lemmas        
        for i in range(0,len(ladr_files)):
            name = os.path.join(os.path.dirname(lemma_names[i]),
                                os.path.basename(ladr_files[i].replace(filemgt.read_config('ladr','ending'),'')))
            #print "NAME = " + name
            m = LemmaModule(name,ladr_files[i],tptp_sentences[i])
            self.lemmas.append(m)
예제 #15
0
def get_version(self):
    vampire = process.startInteractiveProcess(filemgt.read_config('vampire','command') + ' --version')
    # only one line as output expected
    return vampire.stdout.readline()
        
예제 #16
0
 def get_returncodes(self,name,type="positive_returncode"):
     codes = filemgt.read_config(name,type).split(',')
     codes = [ int(s.strip()) for s in codes ]
     return codes