@@ -80,12 +80,12 @@ Function: states_equal
80
80
exprt states_equal (
81
81
std::size_t i,
82
82
std::size_t k,
83
- const std::vector<symbol_exprt> &state_vars )
83
+ const std::vector<symbol_exprt> &variables_to_compare )
84
84
{
85
85
exprt::operandst conjuncts;
86
- conjuncts.reserve (state_vars .size ());
86
+ conjuncts.reserve (variables_to_compare .size ());
87
87
88
- for (auto &var : state_vars )
88
+ for (auto &var : variables_to_compare )
89
89
{
90
90
auto i_var = timeframe_symbol (i, var);
91
91
auto k_var = timeframe_symbol (k, var);
@@ -131,8 +131,12 @@ void lasso_constraints(
131
131
const namespacet &ns,
132
132
const irep_idt &module_identifier)
133
133
{
134
+ // The definition of a lasso to state s_i is that there
135
+ // is an identical state s_k = s_i with k<i.
136
+ // "Identical" is defined as "state variables and top-level inputs match".
137
+
134
138
// gather the state variables
135
- std::vector<symbol_exprt> state_vars ;
139
+ std::vector<symbol_exprt> variables_to_compare ;
136
140
const symbol_tablet &symbol_table = ns.get_symbol_table ();
137
141
138
142
auto lower = symbol_table.symbol_module_map .lower_bound (module_identifier);
@@ -143,7 +147,23 @@ void lasso_constraints(
143
147
const symbolt &symbol = ns.lookup (it->second );
144
148
145
149
if (symbol.is_state_var )
146
- state_vars.push_back (symbol.symbol_expr ());
150
+ variables_to_compare.push_back (symbol.symbol_expr ());
151
+ }
152
+
153
+ // gather the top-level inputs
154
+ const auto &module_symbol = ns.lookup (module_identifier);
155
+ DATA_INVARIANT (module_symbol.type .id () == ID_module, " expected a module" );
156
+ const auto &ports = module_symbol.type .find (ID_ports);
157
+
158
+ for (auto &port : static_cast <const exprt &>(ports).operands ())
159
+ {
160
+ DATA_INVARIANT (port.id () == ID_symbol, " port must be a symbol" );
161
+ if (port.get_bool (ID_input) && !port.get_bool (ID_output))
162
+ {
163
+ symbol_exprt input_symbol (port.get (ID_identifier), port.type ());
164
+ input_symbol.add_source_location () = port.source_location ();
165
+ variables_to_compare.push_back (std::move (input_symbol));
166
+ }
147
167
}
148
168
149
169
for (std::size_t i = 1 ; i < no_timeframes; i++)
@@ -153,7 +173,7 @@ void lasso_constraints(
153
173
disjuncts.reserve (i);
154
174
155
175
for (std::size_t k = 0 ; k < i; k++)
156
- disjuncts.push_back (states_equal (k, i, state_vars ));
176
+ disjuncts.push_back (states_equal (k, i, variables_to_compare ));
157
177
158
178
auto lasso_symbol = ::lasso_symbol (i);
159
179
solver.set_to_true (equal_exprt (lasso_symbol, disjunction (disjuncts)));
0 commit comments