3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-05 07:23:58 +00:00

load str decl plugin; recognize String sorted constants

This commit is contained in:
Murphy Berzish 2015-09-06 20:53:08 -04:00
parent 744d2e3c9c
commit 8137e022e3
8 changed files with 190 additions and 1 deletions

View file

@ -31,6 +31,7 @@ Revision History:
#include"theory_dl.h"
#include"theory_seq_empty.h"
#include"theory_fpa.h"
#include"theory_str.h"
namespace smt {
@ -117,6 +118,8 @@ namespace smt {
setup_QF_FP();
else if (m_logic == "QF_FPBV")
setup_QF_FPBV();
else if (m_logic == "QF_S")
setup_QF_S();
else
setup_unknown();
}
@ -158,6 +161,8 @@ namespace smt {
setup_QF_BVRE();
else if (m_logic == "QF_AUFLIA")
setup_QF_AUFLIA(st);
else if (m_logic == "QF_S")
setup_QF_S();
else if (m_logic == "AUFLIA")
setup_AUFLIA(st);
else if (m_logic == "AUFLIRA")
@ -694,6 +699,11 @@ namespace smt {
m_context.register_plugin(alloc(smt::theory_fpa, m_manager));
}
void setup::setup_QF_S() {
setup_QF_LIA();
m_context.register_plugin(alloc(smt::theory_str, m_manager));
}
bool is_arith(static_features const & st) {
return st.m_num_arith_ineqs > 0 || st.m_num_arith_terms > 0 || st.m_num_arith_eqs > 0;
}
@ -800,6 +810,11 @@ namespace smt {
m_context.register_plugin(alloc(theory_fpa, m_manager));
}
void setup::setup_str() {
setup_arith();
m_context.register_plugin(alloc(theory_str, m_manager));
}
void setup::setup_unknown() {
setup_arith();
setup_arrays();
@ -808,6 +823,7 @@ namespace smt {
setup_dl();
setup_seq();
setup_fpa();
setup_str();
}
void setup::setup_unknown(static_features & st) {
@ -906,6 +922,8 @@ namespace smt {
return;
}
// TODO setup_str() by features
setup_unknown();
}

View file

@ -77,6 +77,7 @@ namespace smt {
void setup_QF_AUFLIA(static_features const & st);
void setup_QF_FP();
void setup_QF_FPBV();
void setup_QF_S();
void setup_LRA();
void setup_AUFLIA(bool simple_array = true);
void setup_AUFLIA(static_features const & st);
@ -98,6 +99,7 @@ namespace smt {
void setup_i_arith();
void setup_mi_arith();
void setup_fpa();
void setup_str();
public:
setup(context & c, smt_params & params);

97
src/smt/theory_str.cpp Normal file
View file

@ -0,0 +1,97 @@
/*++
Module Name:
theory_str.cpp
Abstract:
String Theory Plugin
Author:
Murphy Berzish (mtrberzi) 2015-09-03
Revision History:
--*/
#include"ast_smt2_pp.h"
#include"smt_context.h"
#include"theory_str.h"
#include"smt_model_generator.h"
namespace smt {
theory_str::theory_str(ast_manager &m):
theory(m.mk_family_id("str"))
{
}
theory_str::~theory_str() {
}
bool theory_str::internalize_atom(app * atom, bool gate_ctx) {
// TODO I have no idea if this is correct.
TRACE("t_str", tout << "internalizing atom: " << mk_ismt2_pp(atom, get_manager()) << "\n";);
SASSERT(atom->get_family_id() == get_family_id());
ast_manager & m = get_manager();
context & ctx = get_context();
if (ctx.b_internalized(atom))
return true;
unsigned num_args = atom->get_num_args();
for (unsigned i = 0; i < num_args; i++)
ctx.internalize(atom->get_arg(i), false);
literal l(ctx.mk_bool_var(atom));
ctx.set_var_theory(l.var(), get_id());
return true;
}
bool theory_str::internalize_term(app * term) {
// TODO I have no idea if this is correct either.
ast_manager & m = get_manager();
context & ctx = get_context();
TRACE("t_str", tout << "internalizing term: " << mk_ismt2_pp(term, get_manager()) << "\n";);
SASSERT(term->get_family_id() == get_family_id());
SASSERT(!ctx.e_internalized(term));
unsigned num_args = term->get_num_args();
for (unsigned i = 0; i < num_args; i++)
ctx.internalize(term->get_arg(i), false);
enode * e = (ctx.e_internalized(term)) ? ctx.get_enode(term) :
ctx.mk_enode(term, false, false, true);
if (is_attached_to_var(e))
return false;
attach_new_th_var(e);
return true;
}
void theory_str::attach_new_th_var(enode * n) {
context & ctx = get_context();
theory_var v = mk_var(n);
ctx.attach_th_var(n, this, v);
TRACE("t_str_detail", tout << "new theory var: " << mk_ismt2_pp(n->get_owner(), get_manager()) << " := " << v << "\n";);
}
void theory_str::new_eq_eh(theory_var x, theory_var y) {
// TODO
TRACE("t_str", tout << "new eq: " << x << " = " << y << std::endl;);
TRACE("t_str_detail", tout << mk_ismt2_pp(get_enode(x)->get_owner(), get_manager()) << " = " <<
mk_ismt2_pp(get_enode(y)->get_owner(), get_manager()) << std::endl;);
}
void theory_str::new_diseq_eh(theory_var x, theory_var y) {
// TODO
TRACE("t_str", tout << "new diseq: " << x << " != " << y << std::endl;);
TRACE("t_str_detail", tout << mk_ismt2_pp(get_enode(x)->get_owner(), get_manager()) << " != " <<
mk_ismt2_pp(get_enode(y)->get_owner(), get_manager()) << std::endl;);
}
}; /* namespace smt */

50
src/smt/theory_str.h Normal file
View file

@ -0,0 +1,50 @@
/*++
Module Name:
theory_str.h
Abstract:
String Theory Plugin
Author:
Murphy Berzish (mtrberzi) 2015-09-03
Revision History:
--*/
#ifndef _THEORY_STR_H_
#define _THEORY_STR_H_
#include"smt_theory.h"
#include"trail.h"
#include"th_rewriter.h"
#include"value_factory.h"
#include"smt_model_generator.h"
namespace smt {
class str_value_factory : public value_factory {
// TODO
};
class theory_str : public theory {
// TODO
protected:
virtual bool internalize_atom(app * atom, bool gate_ctx);
virtual bool internalize_term(app * term);
virtual void new_eq_eh(theory_var, theory_var);
virtual void new_diseq_eh(theory_var, theory_var);
virtual theory* mk_fresh(context*) { return alloc(theory_str, get_manager()); }
public:
theory_str(ast_manager& m);
virtual ~theory_str();
protected:
void attach_new_th_var(enode * n);
};
};
#endif /* _THEORY_STR_H_ */