3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-25 18:15:32 +00:00

adding ematching engine, fixing seq_unicode

This commit is contained in:
Nikolaj Bjorner 2021-01-22 17:10:45 -08:00
parent db17ae03c6
commit 680b185872
10 changed files with 4147 additions and 20 deletions

View file

@ -3,6 +3,7 @@ z3_add_component(euf
euf_enode.cpp
euf_etable.cpp
euf_egraph.cpp
euf_mam.cpp
COMPONENT_DEPENDENCIES
ast
util

View file

@ -247,6 +247,8 @@ namespace euf {
*/
bool are_diseq(enode* a, enode* b) const;
enode * get_enode_eq_to(func_decl * f, unsigned num_args, enode * const * args) { UNREACHABLE(); return nullptr; }
/**
\brief Maintain and update cursor into propagated consequences.
The result of get_literal() is a pair (n, is_eq)
@ -279,6 +281,11 @@ namespace euf {
template <typename T>
void explain_eq(ptr_vector<T>& justifications, enode* a, enode* b);
enode_vector const& nodes() const { return m_nodes; }
ast_manager& get_manager() { return m; }
bool is_relevant(enode* n) const { return true; } // TODO
bool resource_limits_exceeded() const { return false; } // TODO
void invariant();
void copy_from(egraph const& src, std::function<void*(void*)>& copy_justification);
struct e_pp {

View file

@ -18,6 +18,7 @@ Author:
#include "util/vector.h"
#include "util/id_var_list.h"
#include "util/lbool.h"
#include "util/approx_set.h"
#include "ast/ast.h"
#include "ast/euf/euf_justification.h"
@ -60,6 +61,9 @@ namespace euf {
th_var_list m_th_vars;
justification m_justification;
unsigned m_num_args{ 0 };
signed char m_lbl_hash { -1 }; // It is different from -1, if enode is used in a pattern
approx_set m_lbls;
approx_set m_plbls;
enode* m_args[0];
friend class enode_args;
@ -138,6 +142,7 @@ namespace euf {
lbool value() const { return m_value; }
unsigned bool_var() const { return m_bool_var; }
bool is_cgr() const { return this == m_cg; }
enode* get_cg() const { return m_cg; }
bool commutative() const { return m_commutative; }
void mark_interpreted() { SASSERT(num_args() == 0); m_interpreted = true; }
bool merge_enabled() const { return m_merge_enabled; }
@ -183,6 +188,16 @@ namespace euf {
unsigned get_expr_id() const { return m_expr->get_id(); }
unsigned get_root_id() const { return m_root->m_expr->get_id(); }
bool children_are_roots() const;
enode* get_next() const { return m_next; }
bool has_lbl_hash() const { UNREACHABLE(); return false; } // TODO
unsigned char get_lbl_hash() const { UNREACHABLE(); return 0; } // TOD0
void set_lbl_hash(egraph& e) { UNREACHABLE(); }
approx_set & get_lbls() { return m_lbls; }
approx_set & get_plbls() { return m_plbls; }
const approx_set & get_lbls() const { return m_lbls; }
const approx_set & get_plbls() const { return m_plbls; }
theory_var get_th_var(theory_id id) const { return m_th_vars.find(id); }
theory_var get_closest_th_var(theory_id id) const;

3968
src/ast/euf/euf_mam.cpp Normal file

File diff suppressed because it is too large Load diff

66
src/ast/euf/euf_mam.h Normal file
View file

@ -0,0 +1,66 @@
/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
euf_mam.h
Abstract:
Matching Abstract Machine
Author:
Leonardo de Moura (leonardo) 2007-02-13.
Nikolaj Bjorner (nbjorner) 2021-01-22.
--*/
#pragma once
#include "ast/ast.h"
#include "ast/euf/euf_egraph.h"
#include <functional>
namespace euf {
/**
\brief Matching Abstract Machine (MAM)
*/
class mam {
friend class mam_impl;
mam() {}
public:
static mam * mk(egraph & ctx,
std::function<void(quantifier*, app*, unsigned, enode* const*, unsigned)>& add_instance);
virtual ~mam() {}
virtual void add_pattern(quantifier * q, app * mp) = 0;
virtual void push_scope() = 0;
virtual void pop_scope(unsigned num_scopes) = 0;
virtual void match() = 0;
virtual void rematch(bool use_irrelevant = false) = 0;
virtual bool has_work() const = 0;
virtual void add_eq_eh(enode * r1, enode * r2) = 0;
virtual void reset() = 0;
virtual std::ostream& display(std::ostream& out) = 0;
virtual void on_match(quantifier * q, app * pat, unsigned num_bindings, enode * const * bindings, unsigned max_generation) = 0;
virtual bool is_shared(enode * n) const = 0;
virtual bool check_missing_instances() = 0;
};
};