The function mata::applications::strings::replace::replace_reluctant_regex often constructs nft_reluctant_replace with
- unnecessary isolated states, and
- multiple consecutive epsilon transitions between two zero-level states.
This does not affect the correctness of the algorithm. However, the redundant epsilon transitions can significantly increase the number of transitions in the composition.
For example, when running the following code:
mata::EnumAlphabet alphabet{ 'a', 'f' };
Nft nft{ mata::applications::strings::replace::replace_reluctant_regex("a", { 'f' }, &alphabet) };
the nft_reluctant_replace inside the mata::applications::strings::replace::replace_reluctant_regex function looks like:
Here, you can see that states 2 and 5 are isolated. Additionally, there is an unnecessary sequence of epsilon transitions: 12--->11--->13--->14--->6
Ideally, states 2 and 5 should not be present, and the epsilon chain should be replaced with a direct transition 10 ---f---> 6.
The function
mata::applications::strings::replace::replace_reluctant_regexoften constructsnft_reluctant_replacewithThis does not affect the correctness of the algorithm. However, the redundant epsilon transitions can significantly increase the number of transitions in the composition.
For example, when running the following code:
mata::EnumAlphabet alphabet{ 'a', 'f' }; Nft nft{ mata::applications::strings::replace::replace_reluctant_regex("a", { 'f' }, &alphabet) };the
nft_reluctant_replaceinside themata::applications::strings::replace::replace_reluctant_regexfunction looks like:Here, you can see that states 2 and 5 are isolated. Additionally, there is an unnecessary sequence of epsilon transitions: 12--->11--->13--->14--->6
Ideally, states 2 and 5 should not be present, and the epsilon chain should be replaced with a direct transition 10 ---f---> 6.