mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
adding dt-solver (#4739)
* adding dt-solver Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * dt Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * move mbp to self-contained module Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * files Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * Create CMakeLists.txt * dt Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * rename to bool_var2expr to indicate type class * mbp * na
This commit is contained in:
parent
b77c57451f
commit
2f756da294
62 changed files with 2309 additions and 1257 deletions
|
@ -896,6 +896,34 @@ bool arith_util::is_extended_numeral(expr* term, rational& r) const {
|
|||
if (is_to_real(term, term)) {
|
||||
continue;
|
||||
}
|
||||
if (is_mul(term)) {
|
||||
rational r(mul), n(0);
|
||||
for (expr* arg : *to_app(term)) {
|
||||
if (!is_extended_numeral(arg, n))
|
||||
return false;
|
||||
r *= n;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (is_add(term)) {
|
||||
rational r(0), n(0);
|
||||
for (expr* arg : *to_app(term)) {
|
||||
if (!is_extended_numeral(arg, n))
|
||||
return false;
|
||||
r += n;
|
||||
}
|
||||
r *= mul;
|
||||
return true;
|
||||
}
|
||||
rational k1, k2;
|
||||
expr* t1, *t2;
|
||||
if (is_sub(term, t1, t2) &&
|
||||
is_extended_numeral(t1, k1) &&
|
||||
is_extended_numeral(t2, k2)) {
|
||||
r = k1 - k2;
|
||||
r *= mul;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} while (false);
|
||||
return false;
|
||||
|
|
|
@ -348,7 +348,7 @@ namespace datatype {
|
|||
MATCH_UNARY(is_recognizer);
|
||||
bool is_accessor(expr const* e) const { return is_app(e) && is_app_of(to_app(e), fid(), OP_DT_ACCESSOR); }
|
||||
MATCH_UNARY(is_accessor);
|
||||
bool is_update_field(app * f) const { return is_app_of(f, fid(), OP_DT_UPDATE_FIELD); }
|
||||
bool is_update_field(expr * f) const { return is_app(f) && is_app_of(to_app(f), fid(), OP_DT_UPDATE_FIELD); }
|
||||
app* mk_is(func_decl * c, expr *f);
|
||||
ptr_vector<func_decl> const * get_datatype_constructors(sort * ty);
|
||||
unsigned get_datatype_num_constructors(sort * ty);
|
||||
|
|
61
src/ast/is_variable_test.h
Normal file
61
src/ast/is_variable_test.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*++
|
||||
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 std::unary_function<expr*,bool> {
|
||||
public:
|
||||
virtual bool operator()(const expr* e) const = 0;
|
||||
};
|
||||
|
||||
class is_variable_test : 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;
|
||||
}
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue