@@ -80,12 +80,12 @@ Function: states_equal
8080exprt states_equal (
8181 std::size_t i,
8282 std::size_t k,
83- const std::vector<symbol_exprt> &state_vars )
83+ const std::vector<symbol_exprt> &variables_to_compare )
8484{
8585 exprt::operandst conjuncts;
86- conjuncts.reserve (state_vars .size ());
86+ conjuncts.reserve (variables_to_compare .size ());
8787
88- for (auto &var : state_vars )
88+ for (auto &var : variables_to_compare )
8989 {
9090 auto i_var = timeframe_symbol (i, var);
9191 auto k_var = timeframe_symbol (k, var);
@@ -131,8 +131,12 @@ void lasso_constraints(
131131 const namespacet &ns,
132132 const irep_idt &module_identifier)
133133{
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+
134138 // gather the state variables
135- std::vector<symbol_exprt> state_vars ;
139+ std::vector<symbol_exprt> variables_to_compare ;
136140 const symbol_tablet &symbol_table = ns.get_symbol_table ();
137141
138142 auto lower = symbol_table.symbol_module_map .lower_bound (module_identifier);
@@ -143,7 +147,23 @@ void lasso_constraints(
143147 const symbolt &symbol = ns.lookup (it->second );
144148
145149 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+ }
147167 }
148168
149169 for (std::size_t i = 1 ; i < no_timeframes; i++)
@@ -153,7 +173,7 @@ void lasso_constraints(
153173 disjuncts.reserve (i);
154174
155175 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 ));
157177
158178 auto lasso_symbol = ::lasso_symbol (i);
159179 solver.set_to_true (equal_exprt (lasso_symbol, disjunction (disjuncts)));
0 commit comments