def _dummy_spec(self, synth_fun): func = semantics_types.SynthFunction( 'pred_indicator_' + str(random.randint(1, 10000000)), synth_fun.function_arity, synth_fun.domain_types, exprtypes.BoolType()) args = [ exprs.FormalParameterExpression(func, argtype, i) for i, argtype in enumerate(synth_fun.domain_types) ] indicator_expr = exprs.FunctionExpression(func, tuple(args)) eval_ctx = evaluation.EvaluationContext() def compute_indicator(term, points): eval_ctx.set_interpretation(func, term) retval = [] for point in points: eval_ctx.set_valuation_map(point) try: retval.append( evaluation.evaluate_expression_raw( indicator_expr, eval_ctx)) except (basetypes.UnboundLetVariableError, basetypes.PartialFunctionError): # Can't mess up on predicates return [False] * len(points) return retval return func, compute_indicator
def make_synth_function(self, function_name, domain_types, range_type): predef_function = self.make_function(function_name, *domain_types) if (predef_function != None): raise ValueError( ('Function named \'%s\' is a predefined function ' + 'given the signature. Could not instantiate it as ' + 'an unknown function') % function_name) mangled_name = semantics_types.mangle_function_name( function_name, domain_types) existing_fun = self.unknown_function_map.get(mangled_name, None) if (existing_fun != None): return existing_fun new_fun = semantics_types.SynthFunction(function_name, len(domain_types), domain_types, range_type) new_fun.synthesis_ctx = self self.unknown_function_map[mangled_name] = new_fun return new_fun