#Good example to demo PyBool. Step through with pdb, and print #variables at each stage. For the recursive representations (expr and expr2) #use Bool.print_expr(expr) for pretty printing. Uses very simple DIMACS #file example_dimacs_files/lecture.cnf if __name__ == "__main__": #Read and parse a dimacs file clauses = Bool.parse_dimacs("example_dimacs_files/lecture.cnf") clauses = clauses["clauses"] #convert dimacs form to recursive form expr = Bool.cnf_to_rec(clauses) #make a new formula that is the negation of previous expr = BoolB.mk_neg_expr(expr) expr2 = copy.deepcopy(expr) #Put in negation normal form expr = Bool.nne(expr) #now make a possibly exp. sized cnf expr = Bool.exp_cnf(expr) #with this expression we make a worst case #polynomial sized cnf expr2 = Bool.poly_cnf(expr2) #Now put the recursive formula back to list form clauses = Bool.cnf_list(expr2)
f = open("python/programoutput/error" + uniqid + ".txt", "w") f.write(ERR_str) f.close() exit(0) if __name__ == "__main__": try: expr = pb.parse_std("python/programoutput/" + uniqid + ".txt")["main_expr"] except pb.Parse_Error as e: ERR_str = "There was an error parsing your file, please check your syntax\n" \ + e.value + "\n" exit_err() if pb.number_vars(expr) > 14: ERR_str = "Your formula contains too many variables for the web interface. Please try again with less than 14 variables or download the PBL package and run it on your own machine." exit_err() if len(pb.print_expr(expr)) > 500: ERR_str = "Your formula is too long for the web interface. Please try again with a smaller formula or download the PBL package and run it on your own machine." exit_err() expr = pb.exp_cnf(expr) STAT_str = pb.print_expr(expr) + "\n" f = open("python/programoutput/programoutput" + uniqid + ".txt", "w") f.write(STAT_str) f.close()
#!/usr/bin/env python import sys import copy sys.path.append("/home/robbean/Uned/sw/PBL/PBL-master/include/") sys.setrecursionlimit(10000) import PyBool_public_interface as Bool if __name__ == "__main__": if len(sys.argv) > 1: clauses = Bool.parse_std(sys.argv[1]) #expr = Bool.exp_cnf(clauses["main_expr"]) nne = Bool.nne(clauses["main_expr"]) cnf = Bool.exp_cnf(nne)
f.write(ERR_str) f.close() exit(0) if __name__ == "__main__": try: expr = pb.parse_std("python/programoutput/" + uniqid + ".txt")["main_expr"] except pb.Parse_Error as e: ERR_str = "There was an error parsing your file, please check your syntax\n" \ + e.value + "\n" exit_err() if pb.number_vars(expr) > PBL_VAR_LENGTH: ERR_str = "Your formula contains too many variables for the web interface. Please try again with less than 14 variables or download the PBL package and run it on your own machine." exit_err() if len(pb.print_expr(expr)) > 500: ERR_str = "Your formula is too long for the web interface. Please try again with a smaller formula or download the PBL package and run it on your own machine." exit_err() expr = pb.exp_cnf(expr) STAT_str = pb.print_expr(expr) + "\n" f = open("python/programoutput/info" + uniqid + ".txt", "w") f.write(STAT_str) f.close()