mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
Reorganizing the code
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
3003ee5cb6
commit
dcf778a287
120 changed files with 10 additions and 4 deletions
64
src/dead/dl_simplifier_plugin.cpp
Normal file
64
src/dead/dl_simplifier_plugin.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*++
|
||||
Copyright (c) 2010 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
dl_simplifier_plugin.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2010-08-10
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#include"dl_simplifier_plugin.h"
|
||||
|
||||
namespace datalog {
|
||||
|
||||
dl_simplifier_plugin::dl_simplifier_plugin(ast_manager& m)
|
||||
: simplifier_plugin(symbol("datalog_relation"), m),
|
||||
m_util(m)
|
||||
{}
|
||||
|
||||
bool dl_simplifier_plugin::reduce(
|
||||
func_decl * f, unsigned num_args, expr* const* args, expr_ref& result) {
|
||||
uint64 v1, v2;
|
||||
switch(f->get_decl_kind()) {
|
||||
case OP_DL_LT:
|
||||
if (m_util.try_get_constant(args[0], v1) &&
|
||||
m_util.try_get_constant(args[1], v2)) {
|
||||
result = (v1 < v2)?m_manager.mk_true():m_manager.mk_false();
|
||||
return true;
|
||||
}
|
||||
// x < x <=> false
|
||||
if (args[0] == args[1]) {
|
||||
result = m_manager.mk_false();
|
||||
return true;
|
||||
}
|
||||
// x < 0 <=> false
|
||||
if (m_util.try_get_constant(args[1], v2) && v2 == 0) {
|
||||
result = m_manager.mk_false();
|
||||
return true;
|
||||
}
|
||||
// 0 < x <=> 0 != x
|
||||
if (m_util.try_get_constant(args[1], v1) && v1 == 0) {
|
||||
result = m_manager.mk_not(m_manager.mk_eq(args[0], args[1]));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
38
src/dead/dl_simplifier_plugin.h
Normal file
38
src/dead/dl_simplifier_plugin.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*++
|
||||
Copyright (c) 2010 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
dl_simplifier_plugin.h
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2010-08-10
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _DL_SIMPLIFIER_PLUGIN_H_
|
||||
#define _DL_SIMPLIFIER_PLUGIN_H_
|
||||
|
||||
#include"dl_decl_plugin.h"
|
||||
#include "simplifier_plugin.h"
|
||||
|
||||
namespace datalog {
|
||||
|
||||
class dl_simplifier_plugin : public simplifier_plugin {
|
||||
dl_decl_util m_util;
|
||||
public:
|
||||
dl_simplifier_plugin(ast_manager& m);
|
||||
|
||||
virtual bool reduce(func_decl * f, unsigned num_args, expr* const* args, expr_ref& result);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
#endif /* _DL_SIMPLIFIER_PLUGIN_H_ */
|
||||
|
131
src/dead/smt_trail.h
Normal file
131
src/dead/smt_trail.h
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*++
|
||||
Copyright (c) 2006 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
smt_trail.h
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2008-02-19.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _SMT_TRAIL_H_
|
||||
#define _SMT_TRAIL_H_
|
||||
|
||||
namespace smt {
|
||||
|
||||
class context;
|
||||
|
||||
class trail {
|
||||
public:
|
||||
virtual ~trail() {
|
||||
}
|
||||
virtual void undo(context & ctx) = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class value_trail : public trail {
|
||||
T & m_value;
|
||||
T m_old_value;
|
||||
|
||||
public:
|
||||
value_trail(T & value):
|
||||
m_value(value),
|
||||
m_old_value(value) {
|
||||
}
|
||||
|
||||
virtual ~value_trail() {
|
||||
}
|
||||
|
||||
virtual void undo(context & ctx) {
|
||||
m_value = m_old_value;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class set_ptr_trail : public trail {
|
||||
T * & m_ptr;
|
||||
public:
|
||||
set_ptr_trail(T * & ptr):
|
||||
m_ptr(ptr) {
|
||||
SASSERT(m_ptr == 0);
|
||||
}
|
||||
|
||||
virtual void undo(context & ctx) {
|
||||
m_ptr = 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, bool CallDestructors=true>
|
||||
class vector_value_trail : public trail {
|
||||
vector<T, CallDestructors> & m_vector;
|
||||
unsigned m_idx;
|
||||
T m_old_value;
|
||||
public:
|
||||
vector_value_trail(vector<T, CallDestructors> & v, unsigned idx):
|
||||
m_vector(v),
|
||||
m_idx(idx),
|
||||
m_old_value(v[idx]) {
|
||||
}
|
||||
|
||||
virtual ~vector_value_trail() {
|
||||
}
|
||||
|
||||
virtual void undo(context & ctx) {
|
||||
m_vector[m_idx] = m_old_value;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, bool CallDestructors=true>
|
||||
class push_back_trail : public trail {
|
||||
vector<T, CallDestructors> & m_vector;
|
||||
public:
|
||||
push_back_trail(vector<T, CallDestructors> & v):
|
||||
m_vector(v) {
|
||||
}
|
||||
|
||||
virtual void undo(context & ctx) {
|
||||
m_vector.pop_back();
|
||||
}
|
||||
};
|
||||
|
||||
class set_bitvector_trail : public trail {
|
||||
svector<bool> & m_vector;
|
||||
unsigned m_idx;
|
||||
public:
|
||||
set_bitvector_trail(svector<bool> & v, unsigned idx):
|
||||
m_vector(v),
|
||||
m_idx(idx) {
|
||||
SASSERT(m_vector[m_idx] == false);
|
||||
m_vector[m_idx] = true;
|
||||
}
|
||||
|
||||
virtual void undo(context & ctx) {
|
||||
m_vector[m_idx] = false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class new_obj_trail : public trail {
|
||||
T * m_obj;
|
||||
public:
|
||||
new_obj_trail(T * obj):
|
||||
m_obj(obj) {
|
||||
}
|
||||
|
||||
virtual void undo(context & ctx) {
|
||||
dealloc(m_obj);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* _SMT_TRAIL_H_ */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue