8 #include "equivalence_oracle.hh"
9 #include "intersection.hh"
11 #include "timed_automaton_runner.hh"
25 std::vector<Alphabet> alphabet;
30 [[nodiscard]] std::optional<TimedWord> subset(
TimedAutomaton hypothesis)
const {
32 boost::unordered_map<std::pair<TAState *, TAState *>, std::shared_ptr<TAState>> toIState;
33 BOOST_LOG_TRIVIAL(debug) <<
"subset: hypothesis\n" << hypothesis;
34 intersectionTA(complement, hypothesis, intersection, toIState);
38 intersection.addUpperBoundForUnobservableTransitions();
39 BOOST_LOG_TRIVIAL(debug) <<
"subset: before ta2za";
40 BOOST_LOG_TRIVIAL(debug) <<
"Number of states: " << intersection.
stateSize();
41 BOOST_LOG_TRIVIAL(debug) <<
"Number of clock: " << intersection.
clockSize();
42 ta2za(intersection, zoneAutomaton);
43 BOOST_LOG_TRIVIAL(debug) <<
"subset: after ta2za";
45 return zoneAutomaton.sampleWithMemo();
51 [[nodiscard]] std::optional<TimedWord> superset(
const TimedAutomaton& hypothesis)
const {
53 boost::unordered_map<std::pair<TAState *, TAState *>, std::shared_ptr<TAState>> toIState;
54 const auto complementedHypothesis = hypothesis.
complement(this->alphabet);
55 BOOST_LOG_TRIVIAL(debug) <<
"superset: complemented hypothesis\n" << complementedHypothesis;
56 intersectionTA(target, complementedHypothesis, intersection, toIState);
60 intersection.addUpperBoundForUnobservableTransitions();
61 BOOST_LOG_TRIVIAL(debug) <<
"superset: before ta2za";
62 BOOST_LOG_TRIVIAL(debug) <<
"Number of states: " << intersection.
stateSize();
63 BOOST_LOG_TRIVIAL(debug) <<
"Number of clock: " << intersection.
clockSize();
65 BOOST_LOG_TRIVIAL(debug) <<
"superset: after ta2za";
67 return zoneAutomaton.sampleWithMemo();
75 std::vector<Alphabet> alphabet) : target(
std::move(target)),
76 complement(
std::move(complement)),
77 alphabet(
std::move(alphabet)) {
78 BOOST_LOG_TRIVIAL(debug) <<
"Target DTA: \n" << this->target;
79 BOOST_LOG_TRIVIAL(debug) <<
"Complemented target DTA: \n" << this->complement;
87 auto subCounterExample = subset(hypothesis);
88 if (subCounterExample) {
93 hypothesisRunner.pre();
94 for (std::size_t i = 0; i < subCounterExample->wordSize(); ++i) {
95 targetRunner.step(subCounterExample->getDurations().at(i));
96 hypothesisRunner.step(subCounterExample->getDurations().at(i));
97 targetRunner.step(subCounterExample->getWord().at(i));
98 hypothesisRunner.step(subCounterExample->getWord().at(i));
101 assert(targetRunner.step(subCounterExample->getDurations().back()) != hypothesisRunner.step(subCounterExample->getDurations().back()));
103 hypothesisRunner.post();
105 return subCounterExample;
107 auto supCounterExample = superset(hypothesis);
108 if (supCounterExample) {
113 hypothesisRunner.pre();
114 for (std::size_t i = 0; i < supCounterExample->wordSize(); ++i) {
115 targetRunner.step(supCounterExample->getDurations().at(i));
116 hypothesisRunner.step(supCounterExample->getDurations().at(i));
117 targetRunner.step(supCounterExample->getWord().at(i));
118 hypothesisRunner.step(supCounterExample->getWord().at(i));
120 assert(targetRunner.step(supCounterExample->getDurations().back()) != hypothesisRunner.step(supCounterExample->getDurations().back()));
122 hypothesisRunner.post();
125 return supCounterExample;
Equivalence oracle with a timed automaton recognizing the complement of the target language.
Definition: timed_automata_equivalence_oracle.hh:21
std::optional< TimedWord > findCounterExample(const TimedAutomaton &hypothesis) override
Make an equivalence query.
Definition: timed_automata_equivalence_oracle.hh:85
ComplementTimedAutomataEquivalenceOracle(TimedAutomaton target, TimedAutomaton complement, std::vector< Alphabet > alphabet)
Definition: timed_automata_equivalence_oracle.hh:74
Interface of the equivalence oracle.
Definition: equivalence_oracle.hh:17
Class to execute a timed automaton.
Definition: timed_automaton_runner.hh:22
Definition: experiment_runner.hh:23
void ta2za(const TimedAutomaton &TA, ZoneAutomaton &ZA, bool quickReturn=true)
Generate a zone automaton from a timed automaton.
Definition: ta2za.cc:15
Definition: external_transition_maker.hh:149
std::size_t stateSize() const
Returns the number of the states.
Definition: common_types.hh:27
A timed automaton.
Definition: timed_automaton.hh:213
size_t clockSize() const
Returns the number of clock variables used in the timed automaton.
Definition: timed_automaton.hh:252
TimedAutomaton simplify()
Simplify the timed automaton.
Definition: timed_automaton.hh:600
TimedAutomaton simplifyStrong()
Simplify the timed automaton.
Definition: timed_automaton.hh:613
TimedAutomaton complement(const std::vector< Alphabet > &alphabet) const
Take the complement of this timed automaton.
Definition: timed_automaton.hh:261
A Zone automaton.
Definition: zone_automaton.hh:17