#pragma once #include #include #include using std::function; using std::pair; using std::vector; typedef pair Label; typedef pair Edge; const Label epsilon{-1L, 0L}; struct Fsa { long start; vector finals; // sorted vector> adj; // sorted void check() const; long n() const { return adj.size(); } bool is_final(long x) const; bool has(long u, long c) const; bool has_call(long u) const; bool has_call_or_collapse(long u) const; long transit(long u, long c) const; void epsilon_closure(vector& src) const; Fsa operator~() const; // a -> a void accessible(const vector* starts, function relate); // a -> a void co_accessible(const vector* final, function relate); // DFA -> DFA -> DFA Fsa intersect(const Fsa& rhs, function relate) const; // DFA -> DFA -> DFA Fsa difference(const Fsa& rhs, function relate) const; // DFA -> DFA Fsa distinguish(function&)> relate) const; // * -> DFA Fsa determinize(const vector* starts, function&)> relate) const; };