4 #include <unordered_map>
6 #include "intersection.hh"
8 #include "timed_automaton.hh"
9 #include "zone_automaton.hh"
19 std::unordered_map<const TAState *, int> beta;
25 boost::unordered_map<std::pair<TAState *, TAState *>,
26 std::shared_ptr<TAState>>
32 std::unordered_map<TAState *, std::shared_ptr<TAState>> old2new0;
36 std::vector<std::shared_ptr<TAState>> extendedInitialStates(m + 1);
37 std::generate(extendedInitialStates.begin(), extendedInitialStates.end(), std::make_shared<TAState>);
40 for (
auto it = initialState->next.begin(); it != initialState->next.end();
44 const Alphabet c = it->first;
46 extendedInitialStates[0]->next[c].push_back(std::move(edge));
51 std::vector<ClockVariables> allClocks(TA.
clockSize());
52 std::iota(allClocks.begin(), allClocks.end(), 0);
53 for (
int i = 1; i <= m; ++i) {
54 for (
char c = 1; c < CHAR_MAX; ++c) {
55 extendedInitialStates[i]->next[c].push_back(
56 {extendedInitialStates[i - 1].get(), allClocks, {}});
59 auto dummyAcceptingState = std::make_shared<TAState>(
true);
61 for (
char c = 1; c < CHAR_MAX; ++c) {
62 dummyAcceptingState->next[c].push_back(
63 {dummyAcceptingState.get(), {}, {}});
65 for (
auto &state : A0.
states) {
66 for (
auto & it : state->next) {
68 const auto target = edge.
target;
70 if (target && target->isMatch) {
71 edge.
target = dummyAcceptingState.get();
73 it.second.emplace_back(std::move(edge));
79 A0.
states.push_back(dummyAcceptingState);
80 A0.
states.insert(A0.
states.end(), extendedInitialStates.begin(),
81 extendedInitialStates.end());
86 std::unordered_map<TAState *, std::shared_ptr<TAState>> old2newS;
87 old2newS.reserve(TA.
states.size());
89 std::unordered_map<std::shared_ptr<TAState>, std::shared_ptr<TAState>>
91 toDummyState.reserve(TA.
states.size());
92 for (
const auto& state : As.
states) {
93 toDummyState[state] = std::make_shared<TAState>();
94 state->next[0].push_back({toDummyState[state].get(), {}, {}});
96 for (
char c = 1; c < CHAR_MAX; ++c) {
97 toDummyState[state]->next[c].push_back(
98 {toDummyState[state].get(), {}, {}});
102 for (
const auto& dummyState : toDummyState) {
103 As.
states.push_back(dummyState.second);
106 intersectionTA(A0, As, A2, toIState);
109 for (
const auto& origState : TA.
states) {
110 for (
auto &stateAs : As.
states) {
111 stateAs->isMatch = stateAs == old2newS[origState.get()] ||
112 stateAs == toDummyState[old2newS[origState.get()]];
116 for (
int n = 1; n <= m; n++) {
118 updateInitAccepting(A0, As, A2, toIState);
123 beta[origState.get()] = n;
128 beta.insert(std::make_pair(origState.get(), m));
132 inline int at(
const TAState *s)
const {
return beta.at(s); }
133 inline int operator[](
const TAState *s)
const {
return beta.at(s); }
134 inline int at(
const std::shared_ptr<TAState>& s)
const {
return beta.at(s.get()); }
135 inline int operator[](
const std::shared_ptr<TAState>& s)
const {
136 return beta.at(s.get());
The skip value function based on the KMP algorithm for string matching.
Definition: kmp_skip_value.hh:17
std::vector< std::shared_ptr< State > > states
The states of this automaton.
Definition: common_types.hh:14
std::vector< std::shared_ptr< State > > initialStates
The initial states of this automaton.
Definition: common_types.hh:19
A state of timed automata.
Definition: timed_automaton.hh:19
A state of timed automata.
Definition: timed_automaton.hh:42
std::vector< Constraint > guard
The guard for this transition.
Definition: timed_automaton.hh:48
TAState * target
The pointer to the target state.
Definition: timed_automaton.hh:44
A timed automaton.
Definition: timed_automaton.hh:54
void deepCopy(TimedAutomaton &dest, std::unordered_map< TAState *, std::shared_ptr< TAState >> &old2new) const
make a deep copy of this timed automaton.
Definition: timed_automaton.hh:68
size_t clockSize() const
Returns the number of clock variables used in the timed automaton.
Definition: timed_automaton.hh:95
Definition: zone_automaton.hh:55
void updateInitAccepting(const std::vector< std::shared_ptr< TAState >> taInitialStates)
Propagate accepting states from the original timed automaton.
Definition: zone_automaton.hh:116
bool empty() const
emptiness check of the language
Definition: zone_automaton.hh:136