3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-10 09:48:05 +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

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 */