Automatically remove dead states from concatenated automata. #14205
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Concatenating automata frequently creates dead states. This PR suggests that
Operations#concatenate
automatically removes these dead states. This is not unseen:Operations#repeat
,Operations#union
and other automaton manipulation utilities also automatically remove dead states.Here is an example of what concatenating automata that accept "f" and "g" returns, without this patch:
![automaton](https://private-user-images.githubusercontent.com/299848/410426651-3076e674-d38a-4230-a801-3fdfb5fbc15a.svg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MTUwNDQsIm5iZiI6MTczODkxNDc0NCwicGF0aCI6Ii8yOTk4NDgvNDEwNDI2NjUxLTMwNzZlNjc0LWQzOGEtNDIzMC1hODAxLTNmZGZiNWZiYzE1YS5zdmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QwNzUyMjRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wNGJjNGNmNWZlZWMxZjIzZmQ4NDM0ZTA5NTkzNzEzOGFlY2MxMzVlNjY1NTUxOWM2NTMwZjRlOTFkY2M1OTQ3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ks5G7dgcv0LANQRTPB6leggngqLvclJaDbq9tvqcuog)
With this patch, state 3 gets removed.
Relates #14193.