def run_lemma(self, lemma_name, lemma_file, output_file_infix=''): p9_lemma_file_name = filemgt.get_name_with_subfolder( lemma_name, read_config('output', 'folder'), output_file_infix + read_config('prover9', 'ending')) p9cmd = ladr.get_p9_cmd( self.imports) + lemma_file + ' > ' + p9_lemma_file_name print(p9cmd) m4_lemma_file_name = filemgt.get_name_with_subfolder( lemma_name, read_config('output', 'folder'), output_file_infix + read_config('mace4', 'ending')) m4cmd = ladr.get_m4_cmd( self.imports) + lemma_file + ' > ' + m4_lemma_file_name print(m4cmd) # run both prover9 and mace4 simultaneously and wait until one returns provers = {p9cmd: {0, 101, 102}} finders = {m4cmd: {0, 3, 4, 101, 102}} # run both prover9 and mace4 simultaneously and wait until one returns (prc, frc) = process.raceProcesses(provers, finders) if frc['mace4'] == 0: print('Counterexample found') return False elif prc['prover9'] == 0: print('Lemma proved') return True elif frc['mace4'] == 2: print( 'Mace unable to find a counterexample in the given range of domain sizes' ) return None elif prc['prover9'] == 2: print('Prover9 unable to construct a proof') return None else: print('result unknown; returncodes (mace4, prover9): ') print(frc['mace4']) print(prc['prover9']) return None
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)
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)
def run_lemma(self, lemma_name, lemma_file, output_file_infix =''): p9_lemma_file_name = filemgt.get_name_with_subfolder(lemma_name, read_config('output','folder'), output_file_infix + read_config('prover9','ending')) p9cmd = ladr.get_p9_cmd(self.imports) + lemma_file + ' > ' + p9_lemma_file_name print p9cmd m4_lemma_file_name = filemgt.get_name_with_subfolder(lemma_name, read_config('output','folder'), output_file_infix + read_config('mace4','ending')) m4cmd = ladr.get_m4_cmd(self.imports) + lemma_file + ' > ' + m4_lemma_file_name print m4cmd # run both prover9 and mace4 simultaneously and wait until one returns provers = {p9cmd: {0,101,102}} finders = {m4cmd: {0,3,4,101,102}} # run both prover9 and mace4 simultaneously and wait until one returns (prc, frc) = process.raceProcesses(provers, finders) if frc['mace4'] == 0: print 'Counterexample found' return False elif prc['prover9'] == 0: print 'Lemma proved' return True elif frc['mace4'] == 2: print 'Mace unable to find a counterexample in the given range of domain sizes' return None elif prc['prover9'] == 2: print 'Prover9 unable to construct a proof' return None else: print 'result unknown; returncodes (mace4, prover9): ' print frc['mace4'] print prc['prover9'] return None
def run_lemmas_with_vampire(self, lemma_name, number, use_previous=False): self.get_single_tptp_file() nonlogical_symbols = self.nonlogical_symbols for symbol in nonlogical_symbols: for special in self.special_symbols: if symbol[0] == special[0]: symbol[0] = special[1] #print self.nonlogical_symbols+self.special_symbols+'\n' vampire = VAMPIRE() for i in range(1, number + 1): self.get_single_tptp_file(i) vampire.lowercase_tptp_file( self.tptp_file_name, self.nonlogical_symbols + self.special_symbols) vampire.select_lemma(self.tptp_file_name, i, number + 1, use_previous) print('--------------------------------------') print('Trying to prove ' + self.tptp_file_name) print('--------------------------------------') vampire_lemma_file_name = filemgt.get_name_with_subfolder( lemma_name, read_config('output', 'folder'), '_' + str(i) + read_config('vampire', 'ending'), ) # vampire command (appending to output single_file) vampire_cmd = vampire.get_vampire_basic_cmd( self.tptp_file_name) + ' >> ' + vampire_lemma_file_name print(vampire_cmd) # edit vampire_lemma_file to include basic information about execution data, time and command single_file = open(vampire_lemma_file_name, 'w') single_file.write( '============================= Vampire ================================\n' ) single_file.write(vampire.get_version() + '\n') now = datetime.datetime.now() single_file.write(now.strftime("%a %b %d %H:%M:%S %Y") + '\n') single_file.write('The command was \"' + vampire_cmd + '\"\n') single_file.write( '============================== end of head ===========================\n' ) single_file.close() vampire.run_vampire(vampire_cmd)
def run_lemmas_with_vampire(self, lemma_name, number, use_previous=False): self.get_single_tptp_file() nonlogical_symbols = self.nonlogical_symbols for symbol in nonlogical_symbols: for special in self.special_symbols: if symbol[0]==special[0]: symbol[0]= special[1] #print self.nonlogical_symbols+self.special_symbols+'\n' vampire = VAMPIRE() for i in range(1, number+1): self.get_single_tptp_file(i) vampire.lowercase_tptp_file(self.tptp_file_name, self.nonlogical_symbols+self.special_symbols) vampire.select_lemma(self.tptp_file_name,i, number+1, use_previous) print '--------------------------------------' print 'Trying to prove ' + self.tptp_file_name print '--------------------------------------' vampire_lemma_file_name = filemgt.get_name_with_subfolder(lemma_name, read_config('output','folder'), '_' + str(i)+ read_config('vampire','ending'),) # vampire command (appending to output single_file) vampire_cmd = vampire.get_vampire_basic_cmd(self.tptp_file_name) + ' >> ' + vampire_lemma_file_name print vampire_cmd # edit vampire_lemma_file to include basic information about execution data, time and command single_file = open(vampire_lemma_file_name, 'w') single_file.write('============================= Vampire ================================\n') single_file.write(vampire.get_version()+'\n') now = datetime.datetime.now() single_file.write(now.strftime("%a %b %d %H:%M:%S %Y")+'\n') single_file.write('The command was \"' + vampire_cmd + '\"\n') single_file.write('============================== end of head ===========================\n') single_file.close() vampire.run_vampire(vampire_cmd)