concepts.dsl.learning.function_domain_search.FunctionDomainExpressionEnumerativeSearcher#

class FunctionDomainExpressionEnumerativeSearcher[source]#

Bases: object

An enumerator of expressions and functions for a function domain.

Methods

gen([return_type, max_depth, ...])

gen_constant_expressions([return_type])

Generate constant expressions of a set of given types.

gen_function_application_expressions([...])

Generate functions and function application expressions of a set of given types.

__init__(domain)[source]#

Initialize the searcher.

Parameters:

domain (DSLDomainBase) – the domain of the semantics.

__new__(**kwargs)#
gen(return_type=None, *, max_depth=3, max_variable_arguments=2, max_constant_arguments=1, max_function_arguments=0, search_constants=False, hash_function=None, verbose=False)[source]#
Parameters:
gen_constant_expressions(return_type=None)[source]#

Generate constant expressions of a set of given types.

Parameters:

return_type (ObjectType | ValueType | FunctionType | Tuple[ObjectType | ValueType | FunctionType, ...] | List[ObjectType | ValueType | FunctionType] | None) – the return type of the expressions. If None, all types are allowed. It can be a single type, a tuple of types, or a list of types.

Returns:

A list of constant expressions.

Return type:

List[FunctionDomainExpressionSearchResult]

gen_function_application_expressions(return_type=None, *, max_depth=3, max_variable_arguments=2, max_constant_arguments=1, max_function_arguments=0, search_constants=False, hash_function=None, verbose=False)[source]#

Generate functions and function application expressions of a set of given types.

Parameters:
  • max_depth (int) – the maximum depth of the expressions.

  • return_type (ObjectType | ValueType | FunctionType | Tuple[ObjectType | ValueType | FunctionType, ...] | List[ObjectType | ValueType | FunctionType] | None) – the return type of the expressions. If None, all types are allowed. It can be a single type, a tuple of types, or a list of types.

  • max_variable_arguments (int) – the maximum number of variable arguments of the functions.

  • max_constant_arguments (int) – the maximum number of constant arguments of the functions. Note that when search_constants is True, this parameter corresponds to the maximum number of constant arguments bound to the function / function application expression.

  • max_function_arguments (int) – the maximum number of arguments of the functions.

  • search_constants (bool) – whether to search for constants.

  • verbose (bool) – whether to print the search progress.

  • hash_function (Callable[[Function | FunctionApplicationExpression], Any] | None)

Returns:

A list of function application expressions.

Return type:

List[FunctionDomainExpressionSearchResult]