def do(solver_t, ws, steps, w_min, w_max, search_t, diag, var_t, var_d): if solver_t == 'boolector': import src.solver.boolector as solver elif solver_t == 'cryptominisat': import src.solver.cryptominisat as solver elif solver_t == 'stp': import src.solver.stp as solver else: print 'Unknown solver!' return w = w_min solutions = [] print 'DFS: {} {} {} {}'.format(solver_t, search_t, ws, steps) while w <= w_max: print '{}'.format(w), sys.stdout.flush() norx = NORX(ws, steps, w, search_t, diag) if var_t in norx.set_variables.keys(): norx.set_variables[var_t](var_d) # setup search problem for solver sp = setup.do(stdin=norx(), flags=setup.TFLAGS[solver_t]) # solve output = solver.do(stdin=sp) if solver.SIGNAL in output: w += 1 else: print "Differential found. Weight: {}".format(w), v = [] if solver_t in ['boolector', 'stp']: differential = solver.parse(output) print differential print output x = norx.extract_input(differential) z = norx.extract_output(differential) v = [str(w)] + [x[key] for key in sorted(x.keys())] + [ str(w) ] + [z[key] for key in sorted(z.keys())] else: v = [str(w), output] solutions.append(v) break print '' return solutions
def do( solver_t, ws, steps, w_min, w_max, search_t, diag, var_t, var_d ): if solver_t == 'boolector': import src.solver.boolector as solver elif solver_t == 'cryptominisat': import src.solver.cryptominisat as solver elif solver_t == 'stp': import src.solver.stp as solver else: print 'Unknown solver!' return w = w_min solutions = [] print 'DFS: {} {} {} {}'.format( solver_t, search_t, ws, steps ) while w <= w_max: print '{}'.format(w), sys.stdout.flush() norx = NORX( ws, steps, w, search_t, diag ) if var_t in norx.set_variables.keys(): norx.set_variables[var_t]( var_d ) # setup search problem for solver sp = setup.do( stdin = norx(), flags = setup.TFLAGS[solver_t] ) # solve output = solver.do( stdin = sp ) if solver.SIGNAL in output: w += 1 else: print "Differential found. Weight: {}".format( w ), v = [] if solver_t in ['boolector','stp']: differential = solver.parse( output ) print differential print output x = norx.extract_input( differential ) z = norx.extract_output( differential ) v = [ str(w) ] + [ x[key] for key in sorted( x.keys() ) ] + [ str(w) ] + [ z[key] for key in sorted( z.keys() ) ] else: v = [ str(w), output ] solutions.append(v) break print '' return solutions
def do(solver_t, ws, steps, weight, enum_max, search_t, diag): if solver_t == "boolector": import src.solver.boolector as solver elif solver_t == "stp": import src.solver.stp as solver else: print "Unknown solver!" return norx = NORX(ws, steps, weight, search_t, diag) i = 1 solutions = [] print "ENUM: {} {} {} {} {} {}".format(solver_t, search_t, ws, steps, weight, enum_max) while i != enum_max: print "{}".format(i), sys.stdout.flush() # setup search problem for solver sp = setup.do(stdin=norx(), flags=setup.TFLAGS[solver_t]) # solve output = solver.do(stdin=sp) if solver.SIGNAL in output: print "Done." break else: differential = solver.parse(output) x = norx.extract_input(differential) z = norx.extract_output(differential) norx.exclude(x, z) v = ( [str(weight)] + [x[key] for key in sorted(x.keys())] + [str(weight)] + [z[key] for key in sorted(z.keys())] ) solutions.append(v) i += 1 return solutions
def do(solver_t, ws, steps, weight, enum_max, search_t, diag): if solver_t == 'boolector': import src.solver.boolector as solver elif solver_t == 'stp': import src.solver.stp as solver else: print 'Unknown solver!' return norx = NORX(ws, steps, weight, search_t, diag) i = 1 solutions = [] print 'ENUM: {} {} {} {} {} {}'.format(solver_t, search_t, ws, steps, weight, enum_max) while i != enum_max: print '{}'.format(i), sys.stdout.flush() # setup search problem for solver sp = setup.do(stdin=norx(), flags=setup.TFLAGS[solver_t]) # solve output = solver.do(stdin=sp) if solver.SIGNAL in output: print "Done." break else: differential = solver.parse(output) x = norx.extract_input(differential) z = norx.extract_output(differential) norx.exclude(x, z) v = [str(weight)] + [x[key] for key in sorted(x.keys())] + [ str(weight) ] + [z[key] for key in sorted(z.keys())] solutions.append(v) i += 1 return solutions
def cvc(solver_t, ws, steps, w_min, w_max, search_t, diag, var_t, var_d): norx = NORX(ws, steps, w_min, search_t, diag) return norx()
def cvc(solver_t, ws, steps, weight, enum_max, search_t, diag): norx = NORX(ws, steps, weight, search_t, diag) return norx()