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

Implement missing functions #40

Merged
merged 9 commits into from
Aug 12, 2022
Merged

Implement missing functions #40

merged 9 commits into from
Aug 12, 2022

Conversation

Adda0
Copy link
Collaborator

@Adda0 Adda0 commented Aug 11, 2022

Once #36 is merged, this PR will be rebased on the new devel branch and opened for merging. For now, the changes introduced in the new commits since #36 are ready for review.

This PR implements automata operations requested in #25 except for simulation-based minimization (which will be implemented later by @jurajsic).

The implemented operations are:

  • intersection preserving epsilon transitions,
  • check of equivalence of NFAs and
  • concatenation of two NFAs.

Some additional helper functions were introduced, too.

The code has been tested with some simple tests. Nevertheless, it would be beneficial to add more tests for the introduced functions.

In the case of intersection, the previous implementation was reused and updated to give the option to choose between classic and epsilon transitions preserving intersection.

Copy link
Member

@martinhruska martinhruska left a comment

Choose a reason for hiding this comment

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

I'm fine with changes however I am not sure why do you need to have Concatenation and Intersection class in .hh file. Imho it messes the interface and it would be sufficient to keep it in .cc file.

@Adda0
Copy link
Collaborator Author

Adda0 commented Aug 11, 2022

After short discussion, we decided to create new files nfa-concatenation.cc and nfa-intersection.cc for concatenation and intersection implementations, respectively. This way, the underlaying classes Concatenation and Intersection will not be exposed to the public interface and all operations on them will be handled by specific functions in Mata::Nfa::Nfa and/or Mata::Nfa.

Copy link
Member

@tfiedor tfiedor left a comment

Choose a reason for hiding this comment

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

I'm OK with this PR, it's well done.

I'm just wondering, what is the point of rewriting intersection? It seems to be much more complicated and there are lots of tripple nested loops, that could potentially lead to some huge computation time (maybe I'm wrong).

Also I would advise against having PR that includes changes of other PR :).

include/mata/nfa.hh Outdated Show resolved Hide resolved
src/nfa/nfa-incl.cc Show resolved Hide resolved
src/nfa/nfa.cc Outdated Show resolved Hide resolved
src/nfa/nfa.cc Outdated Show resolved Hide resolved
src/nfa/nfa.cc Outdated Show resolved Hide resolved
src/nfa/nfa.cc Outdated Show resolved Hide resolved
@Adda0
Copy link
Collaborator Author

Adda0 commented Aug 11, 2022

I'm just wondering, what is the point of rewriting intersection? It seems to be much more complicated and there are lots of tripple nested loops, that could potentially lead to some huge computation time (maybe I'm wrong).

The code implementing the normal intersection without preserving epsilon transitions is kept the same as the previous implementation of the intersection from Vata2. There were already some TODOs suggesting rewriting the implementation of intersection. The previous long function was only split into multiple smaller ones to reuse some parts of the code common to both non-preserving and preserving intersections. I have used the same code for epsilon preserving intersection, only updated behaviour when epsilon symbol is encountered.

I can understand your concerns regarding computation time requirements. This could use some refactorization. I will inspect the options further and see if I can come up with something suitable. Nevertheless, this could be a good starting point in rewriting the previous intersection implementation, as recommended by the previous TODOs.

Also I would advise against having PR that includes changes of other PR :).

After discussing this with @martinhruska, we agreed on creating this and #41 PRs to allow quicker reviews. The code would not compile without commits from #36. When #36 is merged, this PR will be rebased on the new devel branch and the changes from #36 will disappear from this PR. Only then will I change this PR from draft PR to a normal PR and open this PR for merging (and “officially” for reviews).

@tfiedor
Copy link
Member

tfiedor commented Aug 11, 2022

Also I would advise against having PR that includes changes of other PR :).

After discussion with @martinhruska, we agreed on creating this and #41 PRs to allow quicker reviews. The code would not compile without commits from #36. When #36 is merged, this PR will be rebased on the new devel branch and the changes from #36 will disappear from this PR. Only then will I change this PR from draft PR to a normal PR and open this PR for merging (and “officially” for reviews).

I assumed, this was the case, so I'm just "warning" against this practice to be "standard" in future :-).

@Adda0
Copy link
Collaborator Author

Adda0 commented Aug 11, 2022

Dully noted. The alternative solution would be to create these PRs on my fork of Mata and point you there for the reviews. For the possible future uses (I really hope that will not be necessary), would you as a reviewer prefer the redirection to other repository to this approach? Or, do you have a better idea how to solve this?

I could not find a cleaner solution. I could create a new branch directly on VeriFIT/Mata for segmentation, another for this PR and yet one more for noodlification. Then I could create a new PR for each new branch, do the code reviews, close the PRs and create these PRs, already rebased on the updated devel branch.

@martinhruska
Copy link
Member

We need to fix the process to not let you wait for 10 days on our reviews. Then this hacking with PRs would not be necessary.

@Adda0 Adda0 marked this pull request as ready for review August 12, 2022 11:41
@Adda0
Copy link
Collaborator Author

Adda0 commented Aug 12, 2022

All issues with this PR are resolved and the changes we agreed upon are applied.

Please, feel free to review the new changes (commits 6cf1054 and further). I have moved concatenation and intersection implementation to their own .cc files, added the requested warning, removed the deprecated optimization checks and used Intersection::compute(lhs, rhs) instead of calling the constructor of class Intersection directly.

Otherwise, from where I stand, the PR is finished. After these potential reviews, the PR is ready to be merged.

@martinhruska martinhruska merged commit 167b383 into VeriFIT:devel Aug 12, 2022
@Adda0 Adda0 deleted the implement_missing_functions branch August 12, 2022 14:38
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.

3 participants