@@ -51,68 +51,3 @@ lambda_exprt::lambda_exprt(const variablest &_variables, const exprt &_where)
51
51
lambda_type (_variables, _where))
52
52
{
53
53
}
54
-
55
- static optionalt<exprt> substitute_symbols_rec (
56
- const std::map<irep_idt, exprt> &substitutions,
57
- exprt src)
58
- {
59
- if (src.id () == ID_symbol)
60
- {
61
- auto s_it = substitutions.find (to_symbol_expr (src).get_identifier ());
62
- if (s_it == substitutions.end ())
63
- return {};
64
- else
65
- return s_it->second ;
66
- }
67
-
68
- if (!src.has_operands ())
69
- return {};
70
-
71
- bool op_changed = false ;
72
-
73
- for (auto &op : src.operands ())
74
- {
75
- auto op_result = substitute_symbols_rec (substitutions, op);
76
-
77
- if (op_result.has_value ())
78
- {
79
- op = op_result.value ();
80
- op_changed = true ;
81
- }
82
- }
83
-
84
- if (op_changed)
85
- return src;
86
- else
87
- return {};
88
- }
89
-
90
- exprt lambda_exprt::application (const operandst &arguments) const
91
- {
92
- // number of arguments must match function signature
93
- auto &variables = this ->variables ();
94
- PRECONDITION (variables.size () == arguments.size ());
95
-
96
- std::map<symbol_exprt, exprt> value_map;
97
-
98
- for (std::size_t i = 0 ; i < variables.size (); i++)
99
- {
100
- // types must match
101
- PRECONDITION (variables[i].type () == arguments[i].type ());
102
- value_map[variables[i]] = arguments[i];
103
- }
104
-
105
- // build a subsitution map
106
- std::map<irep_idt, exprt> substitutions;
107
-
108
- for (std::size_t i = 0 ; i < variables.size (); i++)
109
- substitutions[variables[i].get_identifier ()] = arguments[i];
110
-
111
- // now recurse downwards and substitute in 'where'
112
- auto substitute_result = substitute_symbols_rec (substitutions, where ());
113
-
114
- if (substitute_result.has_value ())
115
- return substitute_result.value ();
116
- else
117
- return where (); // trivial case, variables not used
118
- }
0 commit comments