Skip to content

Commit aec0b8b

Browse files
committed
Explicitly scolemise quantifier bound variables in goto_check_rec.
Add a special case handling for `forall` and `exists` expressions to have their bound variables instantiated by a new symbol, in effect performing a scolem transformation over it.
1 parent d821c53 commit aec0b8b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/analyses/goto_check.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ Author: Daniel Kroening, [email protected]
2222
#include <util/expr_util.h>
2323
#include <util/find_symbols.h>
2424
#include <util/floatbv_expr.h>
25+
#include <util/fresh_symbol.h>
2526
#include <util/ieee_float.h>
2627
#include <util/invariant.h>
2728
#include <util/make_unique.h>
29+
#include <util/mathematical_expr.h>
2830
#include <util/options.h>
2931
#include <util/pointer_expr.h>
3032
#include <util/pointer_offset_size.h>
@@ -1747,6 +1749,25 @@ void goto_checkt::check_rec(const exprt &expr, guardt &guard)
17471749
if(check_rec_member(to_member_expr(expr), guard))
17481750
return;
17491751
}
1752+
else if(expr.id() == ID_forall || expr.id() == ID_exists)
1753+
{
1754+
const auto quantified_expr = to_quantifier_expr(expr);
1755+
const auto quantifier_sym = quantified_expr.symbol();
1756+
const auto new_symbol = get_fresh_aux_symbol(
1757+
quantifier_sym.type(),
1758+
CPROVER_PREFIX,
1759+
id2string(ns.lookup(quantifier_sym.get_identifier()).base_name),
1760+
// id2string(quantifier_sym.get_identifier()) + "__scolem_constant",
1761+
quantified_expr.source_location(),
1762+
ID_C,
1763+
const_cast<symbol_table_baset &>(ns.get_symbol_table()));
1764+
const auto symbol_expr =
1765+
symbol_exprt(new_symbol.name, quantifier_sym.type());
1766+
const std::vector<exprt> new_sym_vec{symbol_expr};
1767+
const auto instantiated_expr = quantified_expr.instantiate(new_sym_vec);
1768+
check_rec(instantiated_expr, guard);
1769+
return;
1770+
}
17501771

17511772
forall_operands(it, expr)
17521773
check_rec(*it, guard);

0 commit comments

Comments
 (0)