Skip to content

Commit 63f6830

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 63f6830

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/analyses/goto_check.cpp

Lines changed: 22 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,26 @@ 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+
// In the case of a quantified statement, skolemise the expression
1755+
// and recurse.
1756+
const auto quantified_expr = to_quantifier_expr(expr);
1757+
const auto quantifier_sym = quantified_expr.symbol();
1758+
const auto new_symbol = get_fresh_aux_symbol(
1759+
quantifier_sym.type(),
1760+
CPROVER_PREFIX,
1761+
id2string(ns.lookup(quantifier_sym.get_identifier()).base_name),
1762+
quantified_expr.source_location(),
1763+
ID_C,
1764+
const_cast<symbol_table_baset &>(ns.get_symbol_table()));
1765+
const auto symbol_expr =
1766+
symbol_exprt(new_symbol.name, quantifier_sym.type());
1767+
const std::vector<exprt> new_sym_vec{symbol_expr};
1768+
const auto instantiated_expr = quantified_expr.instantiate(new_sym_vec);
1769+
check_rec(instantiated_expr, guard);
1770+
return;
1771+
}
17501772

17511773
forall_operands(it, expr)
17521774
check_rec(*it, guard);

0 commit comments

Comments
 (0)