def classic_esolver(theory, syn_ctx, synth_funs, grammar_map, specification, verifier): if len(synth_funs) != 1: raise UnsuitableSolverException("Classic esolver for multi-function disable due to bugs") assert len(synth_funs) == 1 try: generator_factory = enumerators.PointDistinctGeneratorFactory(specification) except: raise UnsuitableSolverException("Enumerator problems") TermSolver = termsolvers.PointDistinctTermSolver grammar = grammar_map[synth_funs[0]] term_generator = grammar.to_generator(generator_factory) term_solver = TermSolver(specification.term_signature, term_generator) term_solver.stopping_condition = termsolvers.StoppingCondition.one_term_sufficiency unifier = unifiers.NullUnifier(None, term_solver, synth_funs, syn_ctx, specification) solver = solvers.Solver(syn_ctx) solutions = solver.solve( generator_factory, term_solver, unifier, verifier, verify_term_solve=False ) try: solution = next(solutions) except StopIteration: return "NO SOLUTION" rewritten_solutions = rewrite_solution(synth_funs, solution, reverse_mapping=None) return rewritten_solutions
def memoryless_esolver(theory, syn_ctx, synth_funs, grammar_map, specification, verifier): generator_factory = enumerators.RecursiveGeneratorFactory() TermSolver = termsolvers.PointlessTermSolver if len(synth_funs) > 1: sf_list = [ (synth_fun.function_name, synth_fun, grammar_map[synth_fun]) for synth_fun in synth_funs ] grammar = _merge_grammars(sf_list) else: grammar = grammar_map[synth_funs[0]] term_generator = grammar.to_generator(generator_factory) term_solver = TermSolver(specification.term_signature, term_generator) term_solver.stopping_condition = termsolvers.StoppingCondition.one_term_sufficiency unifier = unifiers.NullUnifier(None, term_solver, synth_funs, syn_ctx, specification) solver = solvers.Solver(syn_ctx) solutions = solver.solve( generator_factory, term_solver, unifier, verifier, verify_term_solve=False ) solution = next(solutions) rewritten_solutions = rewrite_solution(synth_funs, solution, reverse_mapping=None) return rewritten_solutions
def classic_esolver(theory, syn_ctx, synth_funs, grammar_map, specification, verifier, phog_file): if len(synth_funs) != 1: raise UnsuitableSolverException( "Classic esolver for multi-function disable due to bugs") assert len(synth_funs) == 1 try: generator_factory = enumerators.PointDistinctGeneratorFactory( specification) except: raise UnsuitableSolverException("Enumerator problems") TermSolver = termsolvers.PointDistinctTermSolver grammar = grammar_map[synth_funs[0]] term_generator = grammar.to_generator(generator_factory) # init for using PHOG phog = SPhog(grammar, phog_file, synth_funs[0].range_type, specification) if options.use_sphog() else \ Phog(grammar, phog_file, synth_funs[0].range_type) if phog.stat_map is None: print( 'No model available for this problem. We use the classic ESolver ...' ) phog = None term_solver = TermSolver(specification.term_signature, term_generator, stat_model=phog) term_solver.stopping_condition = termsolvers.StoppingCondition.one_term_sufficiency unifier = unifiers.NullUnifier(None, term_solver, synth_funs, syn_ctx, specification) solver = solvers.Solver(syn_ctx) solutions = solver.solve(generator_factory, term_solver, unifier, verifier, verify_term_solve=False) try: solution = next(solutions) except StopIteration: return "NO SOLUTION" rewritten_solutions = rewrite_solution(synth_funs, solution, reverse_mapping=None) return rewritten_solutions