Note
Go to the end to download the full example code.
Higher Order Functions#
EGraph(_flatted_deps=[], _state=EGraphState(egraph=<builtins.EGraph object at 0x55c9c6eec570>, __egg_decls__=Declarations(_unnamed_functions=set(), _functions={'incr_list': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='MathList', args=()),), arg_names=('xs',), arg_defaults=(None,), return_type=TypeRefWithVars(name='MathList', args=()), var_arg_type=None), builtin=False, egg_name=None, cost=None, default=None, on_merge=(), merge=None, unextractable=False)}, _constants={}, _classes={'MathList': ClassDecl(egg_name=None, type_vars=(), builtin=False, init=FunctionDecl(signature=FunctionSignature(arg_types=(), arg_names=(), arg_defaults=(), return_type=TypeRefWithVars(name='MathList', args=()), var_arg_type=None), builtin=False, egg_name=None, cost=None, default=None, on_merge=(), merge=None, unextractable=False), class_methods={}, class_variables={}, methods={'append': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='MathList', args=()), TypeRefWithVars(name='Math', args=())), arg_names=('self', 'i'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='MathList', args=()), var_arg_type=None), builtin=False, egg_name=None, cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'map': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='MathList', args=()), TypeRefWithVars(name='UnstableFn', args=(TypeRefWithVars(name='Math', args=()), TypeRefWithVars(name='Math', args=())))), arg_names=('self', 'f'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='MathList', args=()), var_arg_type=None), builtin=False, egg_name=None, cost=None, default=None, on_merge=(), merge=None, unextractable=False)}, properties={}, preserved_methods={}), 'Math': ClassDecl(egg_name=None, type_vars=(), builtin=False, init=FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()),), arg_names=('i',), arg_defaults=(None,), return_type=TypeRefWithVars(name='Math', args=()), var_arg_type=None), builtin=False, egg_name=None, cost=None, default=None, on_merge=(), merge=None, unextractable=False), class_methods={}, class_variables={}, methods={'__add__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='Math', args=()), TypeRefWithVars(name='Math', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Math', args=()), var_arg_type=None), builtin=False, egg_name=None, cost=None, default=None, on_merge=(), merge=None, unextractable=False)}, properties={}, preserved_methods={}), 'i64': ClassDecl(egg_name=None, type_vars=(), builtin=True, init=None, class_methods={}, class_variables={}, methods={'__add__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='+', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__sub__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='-', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__mul__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='*', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__truediv__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='/', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__mod__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='%', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__and__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='&', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__or__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='|', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__xor__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='^', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__lshift__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='<<', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__rshift__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='>>', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__invert__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()),), arg_names=('self',), arg_defaults=(None,), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='not-i64', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__lt__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Unit', args=()), var_arg_type=None), builtin=True, egg_name='<', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__gt__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Unit', args=()), var_arg_type=None), builtin=True, egg_name='>', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__le__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Unit', args=()), var_arg_type=None), builtin=True, egg_name='<=', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__ge__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Unit', args=()), var_arg_type=None), builtin=True, egg_name='>=', cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'min': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='min', cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'max': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='i64', args=()), var_arg_type=None), builtin=True, egg_name='max', cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'to_string': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()),), arg_names=('self',), arg_defaults=(None,), return_type=TypeRefWithVars(name='String', args=()), var_arg_type=None), builtin=True, egg_name='to-string', cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'bool_lt': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='bool-<', cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'bool_gt': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='bool->', cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'bool_le': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='bool-<=', cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'bool_ge': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='i64', args=()), TypeRefWithVars(name='i64', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='bool->=', cost=None, default=None, on_merge=(), merge=None, unextractable=False)}, properties={}, preserved_methods={}), 'Unit': ClassDecl(egg_name='Unit', type_vars=(), builtin=True, init=None, class_methods={}, class_variables={}, methods={}, properties={}, preserved_methods={}), 'String': ClassDecl(egg_name=None, type_vars=(), builtin=True, init=None, class_methods={}, class_variables={}, methods={'replace': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='String', args=()), TypeRefWithVars(name='String', args=()), TypeRefWithVars(name='String', args=())), arg_names=('self', 'old', 'new'), arg_defaults=(None, None, None), return_type=TypeRefWithVars(name='String', args=()), var_arg_type=None), builtin=True, egg_name='replace', cost=None, default=None, on_merge=(), merge=None, unextractable=False)}, properties={}, preserved_methods={}), 'Bool': ClassDecl(egg_name='bool', type_vars=(), builtin=True, init=None, class_methods={}, class_variables={}, methods={'__invert__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='Bool', args=()),), arg_names=('self',), arg_defaults=(None,), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='not', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__and__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='Bool', args=()), TypeRefWithVars(name='Bool', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='and', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__or__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='Bool', args=()), TypeRefWithVars(name='Bool', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='or', cost=None, default=None, on_merge=(), merge=None, unextractable=False), '__xor__': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='Bool', args=()), TypeRefWithVars(name='Bool', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='xor', cost=None, default=None, on_merge=(), merge=None, unextractable=False), 'implies': FunctionDecl(signature=FunctionSignature(arg_types=(TypeRefWithVars(name='Bool', args=()), TypeRefWithVars(name='Bool', args=())), arg_names=('self', 'other'), arg_defaults=(None, None), return_type=TypeRefWithVars(name='Bool', args=()), var_arg_type=None), builtin=True, egg_name='=>', cost=None, default=None, on_merge=(), merge=None, unextractable=False)}, properties={}, preserved_methods={}), 'UnstableFn': ClassDecl(egg_name=None, type_vars=('T', 'TS'), builtin=True, init=FunctionDecl(signature='fn-partial', builtin=True, egg_name='unstable-fn', cost=None, default=None, on_merge=(), merge=None, unextractable=False), class_methods={}, class_variables={}, methods={'__call__': FunctionDecl(signature='fn-app', builtin=True, egg_name='unstable-app', cost=None, default=None, on_merge=(), merge=None, unextractable=False)}, properties={}, preserved_methods={})}, _rulesets={'': RulesetDecl(rules=[]), 'math_ruleset': RulesetDecl(rules=[DefaultRewriteDecl(ref=UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None), subsume=False), DefaultRewriteDecl(ref=FunctionRef(name='incr_list'), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=PartialCallDecl(call=CallDecl(callable=UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))), args=(), bound_tp_params=None)))), bound_tp_params=None), subsume=False), RewriteDecl(tp=JustTypeRef(name='Math', args=()), lhs=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='i', is_let=False)),), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='j', is_let=False)),), bound_tp_params=()))), bound_tp_params=None), rhs=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=CallDecl(callable=MethodRef(class_name='i64', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='i', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='j', is_let=False))), bound_tp_params=None)),), bound_tp_params=()), conditions=(), subsume=False), RewriteDecl(tp=JustTypeRef(name='MathList', args=()), lhs=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None), rhs=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='UnstableFn', method_name='__call__'), args=(TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False))), bound_tp_params=None))), bound_tp_params=None), conditions=(), subsume=False), RewriteDecl(tp=JustTypeRef(name='MathList', args=()), lhs=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None), rhs=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=()), conditions=(), subsume=False)])}), rulesets={'math_ruleset': {DefaultRewriteDecl(ref=UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None), subsume=False), RewriteDecl(tp=JustTypeRef(name='Math', args=()), lhs=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='i', is_let=False)),), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='j', is_let=False)),), bound_tp_params=()))), bound_tp_params=None), rhs=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=CallDecl(callable=MethodRef(class_name='i64', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='i', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='j', is_let=False))), bound_tp_params=None)),), bound_tp_params=()), conditions=(), subsume=False), RewriteDecl(tp=JustTypeRef(name='MathList', args=()), lhs=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None), rhs=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=()), conditions=(), subsume=False), RewriteDecl(tp=JustTypeRef(name='MathList', args=()), lhs=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None), rhs=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='UnstableFn', method_name='__call__'), args=(TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False))), bound_tp_params=None))), bound_tp_params=None), conditions=(), subsume=False), DefaultRewriteDecl(ref=FunctionRef(name='incr_list'), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=PartialCallDecl(call=CallDecl(callable=UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))), args=(), bound_tp_params=None)))), bound_tp_params=None), subsume=False)}}, egg_fn_to_callable_refs=defaultdict(<class 'set'>, {'!=': {FunctionRef(name='!=')}, 'incr_list': {FunctionRef(name='incr_list')}, 'MathList_append': {MethodRef(class_name='MathList', method_name='append')}, 'MathList___init__': {InitRef(class_name='MathList')}, 'Math___init__': {InitRef(class_name='Math')}, 'Math___add__': {MethodRef(class_name='Math', method_name='__add__')}, 'x-Math__Math___add___x__Math___init___1__': {UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None)))}, 'MathList_map': {MethodRef(class_name='MathList', method_name='map')}, 'unstable-fn': {InitRef(class_name='UnstableFn')}, '+': {MethodRef(class_name='i64', method_name='__add__')}, 'unstable-app': {MethodRef(class_name='UnstableFn', method_name='__call__')}}), callable_ref_to_egg_fn={FunctionRef(name='!='): '!=', FunctionRef(name='incr_list'): 'incr_list', MethodRef(class_name='MathList', method_name='append'): 'MathList_append', InitRef(class_name='MathList'): 'MathList___init__', InitRef(class_name='Math'): 'Math___init__', MethodRef(class_name='Math', method_name='__add__'): 'Math___add__', UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))): 'x-Math__Math___add___x__Math___init___1__', MethodRef(class_name='MathList', method_name='map'): 'MathList_map', InitRef(class_name='UnstableFn'): 'unstable-fn', MethodRef(class_name='i64', method_name='__add__'): '+', MethodRef(class_name='UnstableFn', method_name='__call__'): 'unstable-app'}, type_ref_to_egg_sort={JustTypeRef(name='MathList', args=()): 'MathList', JustTypeRef(name='Math', args=()): 'Math', JustTypeRef(name='i64', args=()): 'i64', JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))): 'UnstableFn_Math_Math', JustTypeRef(name='UnstableFn', args=()): 'UnstableFn'}, expr_to_egg_cache={VarDecl(name='y', is_let=True): Var(Span(SrcFile('<internal.egg>', None), 0, 0), '%y'), CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=()): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList___init__', []), LitDecl(value=1): Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(1)), CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(1))]), CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList___init__', []), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(1))])]), LitDecl(value=2): Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(2)), CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=2)),), bound_tp_params=()): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(2))]), CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=2)),), bound_tp_params=()))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList___init__', []), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(1))])]), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(2))])]), CallDecl(callable=FunctionRef(name='incr_list'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=2)),), bound_tp_params=()))), bound_tp_params=None)),), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'incr_list', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList___init__', []), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(1))])]), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(2))])])]), VarDecl(name='x', is_let=False): Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'x'), CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___add__', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'x'), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(1))])]), CallDecl(callable=UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'x-Math__Math___add___x__Math___init___1__', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'x')]), VarDecl(name='xs', is_let=False): Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'xs'), CallDecl(callable=FunctionRef(name='incr_list'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)),), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'incr_list', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'xs')]), CallDecl(callable=UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))), args=(), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'x-Math__Math___add___x__Math___init___1__', []), PartialCallDecl(call=CallDecl(callable=UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))), args=(), bound_tp_params=None)): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'unstable-fn', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), String('x-Math__Math___add___x__Math___init___1__'))]), CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=PartialCallDecl(call=CallDecl(callable=UnnamedFunctionRef(args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)),), res=TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=1)),), bound_tp_params=()))), bound_tp_params=None))), args=(), bound_tp_params=None)))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_map', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'xs'), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'unstable-fn', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), String('x-Math__Math___add___x__Math___init___1__'))])]), VarDecl(name='i', is_let=False): Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'i'), CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='i', is_let=False)),), bound_tp_params=()): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'i')]), VarDecl(name='j', is_let=False): Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'j'), CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='j', is_let=False)),), bound_tp_params=()): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'j')]), CallDecl(callable=MethodRef(class_name='Math', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='i', is_let=False)),), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='j', is_let=False)),), bound_tp_params=()))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___add__', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'i')]), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'j')])]), CallDecl(callable=MethodRef(class_name='i64', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='i', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='j', is_let=False))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), '+', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'i'), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'j')]), CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=CallDecl(callable=MethodRef(class_name='i64', method_name='__add__'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='i', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=VarDecl(name='j', is_let=False))), bound_tp_params=None)),), bound_tp_params=()): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), '+', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'i'), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'j')])]), CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'xs'), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'x')]), VarDecl(name='f', is_let=False): Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'f'), CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_map', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'xs'), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'x')]), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'f')]), CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_map', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'xs'), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'f')]), CallDecl(callable=MethodRef(class_name='UnstableFn', method_name='__call__'), args=(TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'unstable-app', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'f'), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'x')]), CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=VarDecl(name='xs', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=MethodRef(class_name='UnstableFn', method_name='__call__'), args=(TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=VarDecl(name='x', is_let=False))), bound_tp_params=None))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_map', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'xs'), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'f')]), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'unstable-app', [Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'f'), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'x')])]), CallDecl(callable=MethodRef(class_name='MathList', method_name='map'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='UnstableFn', args=(JustTypeRef(name='Math', args=()), JustTypeRef(name='Math', args=()))), expr=VarDecl(name='f', is_let=False))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_map', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList___init__', []), Var(Span(SrcFile('<internal.egg>', None), 0, 0), 'f')]), CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=2)),), bound_tp_params=()))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList___init__', []), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(2))])]), LitDecl(value=3): Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(3)), CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=3)),), bound_tp_params=()): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(3))]), CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=MethodRef(class_name='MathList', method_name='append'), args=(TypedExprDecl(tp=JustTypeRef(name='MathList', args=()), expr=CallDecl(callable=InitRef(class_name='MathList'), args=(), bound_tp_params=())), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=2)),), bound_tp_params=()))), bound_tp_params=None)), TypedExprDecl(tp=JustTypeRef(name='Math', args=()), expr=CallDecl(callable=InitRef(class_name='Math'), args=(TypedExprDecl(tp=JustTypeRef(name='i64', args=()), expr=LitDecl(value=3)),), bound_tp_params=()))), bound_tp_params=None): Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList_append', [Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'MathList___init__', []), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(2))])]), Call(Span(SrcFile('<internal.egg>', None), 0, 0), 'Math___init__', [Lit(Span(SrcFile('<internal.egg>', None), 0, 0), Int(3))])])}))
from __future__ import annotations
from typing import TYPE_CHECKING
from egglog import *
if TYPE_CHECKING:
from collections.abc import Callable
class Math(Expr):
def __init__(self, i: i64Like) -> None: ...
def __add__(self, other: Math) -> Math: ...
class MathList(Expr):
def __init__(self) -> None: ...
def append(self, i: Math) -> MathList: ...
def map(self, f: Callable[[Math], Math]) -> MathList: ...
@ruleset
def math_ruleset(i: i64, j: i64, xs: MathList, x: Math, f: Callable[[Math], Math]):
yield rewrite(Math(i) + Math(j)).to(Math(i + j))
yield rewrite(xs.append(x).map(f)).to(xs.map(f).append(f(x)))
yield rewrite(MathList().map(f)).to(MathList())
@function(ruleset=math_ruleset)
def incr_list(xs: MathList) -> MathList:
return xs.map(lambda x: x + Math(1))
egraph = EGraph()
y = egraph.let("y", incr_list(MathList().append(Math(1)).append(Math(2))))
egraph.run(math_ruleset.saturate())
egraph.check(eq(y).to(MathList().append(Math(2)).append(Math(3))))
egraph
Total running time of the script: (0 minutes 0.011 seconds)