00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _subset_construction_hh_
00018 #define _subset_construction_hh_
00019
00024 #include <ceta/export.h>
00025 #include <ceta/ta.hh>
00026
00028 namespace ceta {
00030 class CETA_DSO_EXPORT test_result_t {
00031 public:
00033 test_result_t() {
00034 }
00039 test_result_t(const term_t& term, const std::set<state_t>& set)
00040 : impl_(make_pair(term, set)) {
00041 check_kinds(kind(term), set);
00042 }
00047 operator bool() {
00048 return !impl_;
00049 }
00050 private:
00051 typedef std::set<state_t> set_t;
00052 friend const term_t& counterexample(const test_result_t& result);
00053 friend
00054 const std::set<state_t>& reachable_set(const test_result_t& result);
00056 boost::optional< std::pair<term_t, set_t> > impl_;
00057 };
00058
00063 inline
00064 const term_t& counterexample(const test_result_t& result) {
00065 return result.impl_->first;
00066 }
00071 inline
00072 const std::set<state_t>& reachable_set(const test_result_t& result) {
00073 return result.impl_->second;
00074 }
00075
00076 class subset_constructor_impl;
00077
00079 class CETA_DSO_EXPORT subset_constructor_t {
00080 public:
00081 subset_constructor_t(const ta_t& ta);
00083 void work(void);
00085 bool is_complete(void) const;
00087 bool has_next(void) const;
00089 const std::set<state_t>& next_set(void) const;
00091 const term_t& next_term(void) const;
00093 void pop_next(void);
00094 private:
00096 subset_constructor_t(const subset_constructor_t&);
00098 subset_constructor_t& operator=(const subset_constructor_t&);
00100 boost::shared_ptr<subset_constructor_impl> impl_;
00101 };
00102
00107 inline
00108 const test_result_t test_emptiness(const ta_t& ta) {
00109 subset_constructor_t sc(ta);
00110 while (sc.has_next() || !sc.is_complete()) {
00111 if (!sc.has_next())
00112 sc.work();
00113 while (sc.has_next()) {
00114 const std::set<state_t>& set = sc.next_set();
00115 const term_t& term = sc.next_term();
00116 if (models(predicate(ta, kind(term)), set))
00117 return test_result_t(term, set);
00118 sc.pop_next();
00119 }
00120 }
00121 test_result_t accept_result;
00122 return accept_result;
00123 }
00124 }
00125 #endif