3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 04:03:39 +00:00
z3/src/ast/is_variable_test.h
Henrich Lauko 96671cfc73
Add and fix a few general compiler warnings. (#5628)
* rewriter: fix unused variable warnings

* cmake: make missing non-virtual dtors error

* treewide: add missing virtual destructors

* cmake: add a few more checks

* api: add missing virtual destructor to user_propagator_base

* examples: compile cpp example with compiler warnings

* model: fix unused variable warnings

* rewriter: fix logical-op-parentheses warnings

* sat: fix unused variable warnings

* smt: fix unused variable warnings
2021-10-29 15:42:32 +02:00

63 lines
1.3 KiB
C++

/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
qe_vartest.h
Abstract:
Utilities for quantifiers.
Author:
Nikolaj Bjorner (nbjorner) 2013-08-28
Revision History:
--*/
#pragma once
#include "ast/ast.h"
#include "util/uint_set.h"
class is_variable_proc {
public:
virtual ~is_variable_proc() = default;
virtual bool operator()(const expr* e) const = 0;
};
class is_variable_test final : public is_variable_proc {
enum is_var_kind { BY_VAR_SET, BY_VAR_SET_COMPLEMENT, BY_NUM_DECLS };
uint_set m_var_set;
unsigned m_num_decls;
is_var_kind m_var_kind;
public:
is_variable_test(uint_set const& vars, bool index_of_bound) :
m_var_set(vars),
m_num_decls(0),
m_var_kind(index_of_bound?BY_VAR_SET:BY_VAR_SET_COMPLEMENT) {}
is_variable_test(unsigned num_decls) :
m_num_decls(num_decls),
m_var_kind(BY_NUM_DECLS) {}
bool operator()(const expr* e) const override {
if (!is_var(e)) {
return false;
}
unsigned idx = to_var(e)->get_idx();
switch(m_var_kind) {
case BY_VAR_SET:
return m_var_set.contains(idx);
case BY_VAR_SET_COMPLEMENT:
return !m_var_set.contains(idx);
case BY_NUM_DECLS:
return idx < m_num_decls;
}
UNREACHABLE();
return false;
}
};