0
@@ -44,35 +44,96 @@ using namespace std;
0
- typedef pair<state_t, state_t> check_pair_t;
0
+ typedef shared_ptr<check_pair_t> check_pair_p;
0
+ typedef shared_ptr<const check_pair_t> check_pair_cp;
0
+ event_t inbound_event;
0
+ check_pair_t(state_t _spec, state_t _impl):
0
+ inbound_event(HST_ERROR_EVENT)
0
+ check_pair_t(state_t _spec, state_t _impl,
0
+ event_t _inbound_event,
0
+ check_pair_cp _parent):
0
+ inbound_event(_inbound_event),
0
+ bool operator == (const check_pair_t &other) const
0
+ return (spec == other.spec) && (impl == other.impl);
0
struct check_pair_t_hasher
0
unsigned long operator () (const check_pair_t &pair) const
0
- return (pair.first * 33) + pair.second;
0
+ return (pair.spec * 33) + pair.impl;
0
+ unsigned long operator () (check_pair_cp pair) const
0
+ return (pair->spec * 33) + pair->impl;
0
+ void construct_counterexample(trace_counterexample_t &counter,
0
+ trace_counterexample_t result;
0
+ for (check_pair_cp current = pair;
0
+ current->parent.get() != NULL;
0
+ current = current->parent)
0
+ result.trace.push_front(current->inbound_event);
0
+ result.spec_state = pair->spec;
0
+ result.impl_state = pair->impl;
0
+ std::swap(counter,result);
0
typedef judy_set_l<check_pair_t, check_pair_t_hasher>
0
- bool refines(const normalized_lts_t spec_norm, state_t spec_source,
0
+ bool refines(trace_counterexample_t &counter,
0
+ const normalized_lts_t spec_norm, state_t spec_source,
0
const lts_t impl, state_t impl_source)
0
const lts_t &spec = spec_norm.normalized();
0
- check_pair_set_t seen;
0
- deque<check_pair_t> pending;
0
+ check_pair_set_t seen;
0
+ deque<check_pair_cp> pending;
0
* Initialize the BFS sets with the source pair.
0
- check_pair_t source(spec_source, impl_source);
0
+ (new check_pair_t(spec_source, impl_source));
0
pending.push_back(source);
0
@@ -82,12 +143,12 @@ namespace hst
0
while (!pending.empty())
0
- check_pair_
t pair = pending.front();
0
+ check_pair_
cp pair = pending.front();
0
- cerr << "Checking (" << pair.first
0
- << "," << pair.second << ")" << endl;
0
+ cerr << "Checking (" << pair->spec
0
+ << "," << pair->impl << ")" << endl;
0
@@ -97,12 +158,12 @@ namespace hst
0
alphabet_t spec_initials
0
- (spec.state_events_begin(pair.first),
0
- spec.state_events_end(pair.first));
0
+ (spec.state_events_begin(pair->spec),
0
+ spec.state_events_end(pair->spec));
0
alphabet_t impl_initials
0
- (impl.state_events_begin(pair.second),
0
- impl.state_events_end(pair.second));
0
+ (impl.state_events_begin(pair->impl),
0
+ impl.state_events_end(pair->impl));
0
impl_initials -= spec_norm.tau();
0
@@ -111,11 +172,26 @@ namespace hst
0
<< impl_initials << endl;
0
- if (!(spec_initials >= impl_initials))
0
+ * Remove all of the events that both IMPL and SPEC
0
+ * can do. If any are left over, the refinement
0
+ impl_initials -= spec_initials;
0
+ if (impl_initials.size() > 0)
0
cerr << " Nope! Refinement fails." << endl;
0
+ * We can use any of the events left in the set as
0
+ * the counterexample event.
0
+ event_t event = *(impl_initials.begin());
0
+ construct_counterexample(counter, event, pair);
0
@@ -126,8 +202,8 @@ namespace hst
0
for (lts_t::state_pairs_iterator sp_it =
0
- impl.state_pairs_begin(pair.second);
0
- sp_it != impl.state_pairs_end(pair.second);
0
+ impl.state_pairs_begin(pair->impl);
0
+ sp_it != impl.state_pairs_end(pair->impl);
0
event_t event = sp_it->first;
0
@@ -141,11 +217,13 @@ namespace hst
0
* includes a τ-closure.
0
- check_pair_t next(pair.first, impl_prime);
0
+ (new check_pair_t(pair->spec, impl_prime,
0
+ spec_norm.tau(), pair));
0
- if (seen.find(
next) == seen.end())
0
+ if (seen.find(
*next) == seen.end())
0
pending.push_back(next);
0
@@ -159,9 +237,9 @@ namespace hst
0
lts_t::event_target_iterator et_it =
0
- spec.event_targets_begin(pair
.first, event);
0
+ spec.event_targets_begin(pair
->spec, event);
0
- if (et_it == spec.event_targets_end(pair
.first,
0
+ if (et_it == spec.event_targets_end(pair
->spec,
0
@@ -174,7 +252,7 @@ namespace hst
0
state_t spec_prime = *et_it;
0
- if (et_it != spec.event_targets_end(pair
.first,
0
+ if (et_it != spec.event_targets_end(pair
->spec,
0
@@ -184,11 +262,13 @@ namespace hst
0
- check_pair_t next(spec_prime, impl_prime);
0
+ (new check_pair_t(spec_prime, impl_prime,
0
- if (seen.find(
next) == seen.end())
0
+ if (seen.find(
*next) == seen.end())
0
pending.push_back(next);
Comments
No one has commented yet.