Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nfa compose #389

Merged
merged 11 commits into from
Mar 1, 2024
Merged

Nfa compose #389

merged 11 commits into from
Mar 1, 2024

Conversation

koniksedy
Copy link
Collaborator

This pull request includes:

  • Bug fix in the function nft::project_out().
  • Methods Nft::insert_word(), Nft::insert_word_by_parts(), and Nft::insert_identity() for inserting a given word (as one word or a vector of its parts, each for a different level) between source and target states (source and target states are equal for the identity).
  • Functions nft::insert_level() and nft::insert_levels() for inserting levels with a default_symbol on transitions with newly inserted levels. These functions are utilized in matching levels of synchronization between two transducers.
  • Modification of functions nft::intersection() and nft::algorithm::product() to handle transducers with EPSILON and DONT_CARE transitions and a set of auxiliary states (two auxiliary states cannot create a product state).
  • Function nft::compose for computing the composition of two transducers.

@koniksedy koniksedy requested a review from Adda0 February 29, 2024 22:52
Copy link
Collaborator

@Adda0 Adda0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good to me in general. The plan now is to merge this PR immediately, so I can apply the changes here on string solving. Resolve the review issues later on, when there is time.

Furthermore, the things that should be modifed are:

  • nfa::Nfa::insert_word() can have optional target word
  • nft::Nft::insert_word() can have optional target word
  • nft::Nft::insert_word_by_parts() can have optional target word
  • nft::Nft::insert_identity() has an overload with a vector of symbols, creating an identity for all the symbols within.

* @param word The nonempty word to be inserted into the NFA.
* @param tgt The target state where the word ends. It must already be a part of the automaton.
*/
void insert_word(const State src, const Word &word, const State tgt);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future TODO: The target state should be optional and be returned from the function afterwards.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, when the target state will not be specified, the method will create a sequence of states from src (already existing) to tgt (newly created), where tgt does not have any successors and is not a final state. It that correct?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. And the newly created target will be returned from the function so that the user knows where to continue.

Comment on lines +102 to +104
* @param[in] lhs_first_aux_state The first auxiliary state in @p lhs. Two auxiliary states can not form a product state.
* @param[in] rhs_first_aux_state The first auxiliary state in @p rhs. Two auxiliary states con not form a product state.
* @return NFT as a product of NFTs @p lhs and @p rhs with ε handled as regular symbols.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would explain here what are these auxiliary states for.

*/
Nft product(const Nft& lhs, const Nft& rhs, const std::function<bool(State,State)> && final_condition,
const Symbol first_epsilon = EPSILON, std::unordered_map<std::pair<State,State>, State> *prod_map = nullptr);
std::unordered_map<std::pair<State,State>, State> *prod_map = nullptr,
const State lhs_first_aux_state = Limits::max_state, const State rhs_first_aux_state = Limits::max_state);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the states used anywhere in Delta? Because if so, the Limits::max_state of memory is being allocated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, these states are not used in Delta if they are not already a part of it. Essentially, it prevents two states from Delta, which are greater than the specified auxiliary state (implying that these states are auxiliary), from forming a product state.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I kind of saw it in the code later on, but I wanted to make sure.

Comment on lines +7 to +8

#include <fstream>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary import, probably left behind from debugging.

@Adda0 Adda0 merged commit 3447f4d into states_with_levels Mar 1, 2024
9 of 14 checks passed
@Adda0 Adda0 deleted the nfa-compose branch March 1, 2024 06:01
Adda0 added a commit that referenced this pull request Mar 28, 2024
Adda0 added a commit that referenced this pull request Apr 15, 2024
Adda0 added a commit that referenced this pull request Nov 18, 2024
Adda0 added a commit that referenced this pull request Nov 21, 2024
Adda0 added a commit that referenced this pull request Nov 21, 2024
Adda0 added a commit that referenced this pull request Nov 22, 2024
Adda0 added a commit that referenced this pull request Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants