mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 02:45:51 +00:00
add intersection using symbolic automata facility
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
4cf72e23e6
commit
df2d7e7628
8 changed files with 561 additions and 28 deletions
104
src/math/automata/symbolic_automata.h
Normal file
104
src/math/automata/symbolic_automata.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*++
|
||||
Copyright (c) 2015 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
symbolic_automata.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Symbolic Automata over Boolean Algebras, a la Margus Veanes Automata library.
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2016-02-27.
|
||||
|
||||
Revision History:
|
||||
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef SYMBOLIC_AUTOMATA_H_
|
||||
#define SYMBOLIC_AUTOMATA_H_
|
||||
|
||||
|
||||
#include "automaton.h"
|
||||
#include "boolean_algebra.h"
|
||||
|
||||
|
||||
template<class T, class M = default_value_manager<T> >
|
||||
class symbolic_automata {
|
||||
typedef automaton<T, M> automaton_t;
|
||||
typedef boolean_algebra<T*> ba_t;
|
||||
typedef typename automaton_t::move move_t;
|
||||
typedef vector<move_t> moves_t;
|
||||
typedef obj_ref<T, M> ref_t;
|
||||
typedef ref_vector<T, M> refs_t;
|
||||
|
||||
M& m;
|
||||
ba_t& m_ba;
|
||||
|
||||
|
||||
class block {
|
||||
uint_set m_set;
|
||||
unsigned m_rep;
|
||||
bool m_rep_chosen;
|
||||
public:
|
||||
|
||||
block(): m_rep(0), m_rep_chosen(false) {}
|
||||
|
||||
block(uint_set const& s):
|
||||
m_set(s),
|
||||
m_rep(0),
|
||||
m_rep_chosen(false) {
|
||||
}
|
||||
|
||||
block(unsigned_vector const& vs) {
|
||||
for (unsigned i = 0; i < vs.size(); ++i) {
|
||||
m_set.insert(vs[i]);
|
||||
}
|
||||
m_rep_chosen = false;
|
||||
m_rep = 0;
|
||||
}
|
||||
|
||||
block& operator=(block const& b) {
|
||||
m_set = b.m_set;
|
||||
m_rep = 0;
|
||||
m_rep_chosen = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned get_representative() {
|
||||
if (!m_rep_chosen) {
|
||||
uint_set::iterator it = m_set.begin();
|
||||
if (m_set.end() != it) {
|
||||
m_rep = *it;
|
||||
}
|
||||
m_rep_chosen = true;
|
||||
}
|
||||
return m_rep;
|
||||
}
|
||||
|
||||
void add(unsigned i) { m_set.insert(i); }
|
||||
bool contains(unsigned i) const { return m_set.contains(i); }
|
||||
bool is_empty() const { return m_set.empty(); }
|
||||
unsigned size() const { return m_set.num_elems(); }
|
||||
void remove(unsigned i) { m_set.remove(i); m_rep_chosen = false; }
|
||||
void clear() { m_set.reset(); m_rep_chosen = false; }
|
||||
uint_set::iterator begin() { return m_set.begin(); }
|
||||
uint_set::iterator end() { return m_set.end(); }
|
||||
};
|
||||
|
||||
public:
|
||||
symbolic_automata(M& m, ba_t& ba): m(m), m_ba(ba) {}
|
||||
automaton_t* mk_determinstic(automaton_t& a);
|
||||
automaton_t* mk_complement(automaton_t& a);
|
||||
automaton_t* remove_epsilons(automaton_t& a);
|
||||
automaton_t* mk_total(automaton_t& a);
|
||||
automaton_t* mk_minimize(automaton_t& a);
|
||||
automaton_t* mk_product(automaton_t& a, automaton_t& b);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue