-
Notifications
You must be signed in to change notification settings - Fork 21
Extend Mata with counter automata support #548
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
Draft
hiraethese
wants to merge
84
commits into
VeriFIT:devel
Choose a base branch
from
hiraethese:devel
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
6734e53
New cntnfa folder
hiraethese 7f3d5fe
New cntnfa include folder
hiraethese bd63612
Includes are changed and cntnfa is now separated from nfa
hiraethese 53ac4b3
Removed unnecessary includes in cntnfa files
hiraethese 73ccf4c
Minor include fix. Namespace for cntnfa is not fixed.
hiraethese 66a2c1a
Fixed namespace errors. Project is working now.
hiraethese 9ec174a
Changed CounterState to AnnotationState
hiraethese 52224b2
Added annotations and counters basic implementation
hiraethese a03d170
Added counter test and updated implementation of annotations
hiraethese 96e6fa9
Minor changes
hiraethese ec53c4d
Added simple tests for counter NFA
hiraethese 0639251
Minor changes
hiraethese a680b5f
Small fixes and code cleaning
hiraethese b6c2c45
Updated delta for target state
hiraethese fe3b759
Added cntfa methods for annotations
hiraethese ce31262
Minor changes
hiraethese 9698508
Added partial cntnfa tests
hiraethese cf61213
Added constructors for targets in Delta
hiraethese ef5bcf8
Removed unnecessary methods for annotations
hiraethese f82a510
Added basic annotation tests
hiraethese 70f1041
Added insert annotation annotation method for annotation collection
hiraethese 57671b4
Updated annotations and counters
hiraethese 1c948b8
Added basic builder tests for CntNfa
hiraethese 85d9906
Added new parser folder for CNTNFA
hiraethese 64e419a
Implemented basic parser for explicit CNTNFA with annotations
hiraethese 6a4effe
Added counter register set as a part of CNTNFA
hiraethese 9cf4b59
Added comments to CNTNFA parser header file
hiraethese ee749f6
Added convert parsed nfa to CNTNFA function. Need to test.
hiraethese 17bd970
Typo. Changed format of cntnfa-parser header file from .h to .hh
hiraethese 1f3ca1f
Minor change of include error
hiraethese 8251a60
Added empty file for parser
hiraethese b7077f1
Added parse CNTNFA from string method (same as for file)
hiraethese 5004a29
Removed unnecessary parser
hiraethese 7838627
Updated old parser header file for annotations
hiraethese 6fae8cf
Revert changes, better to keep it as it is
hiraethese 2e385f5
Updated counter register implementation and added new construct metho…
hiraethese 1253958
Implemented construct counter NFA
hiraethese 4b766ea
Added test for empty CNTNFA
hiraethese f3f33dd
Updated builder for transitions without annotations. Added simple tests
hiraethese f5726fc
Added tests for CNTNFA with annotations and get_type() for annotations
hiraethese 7c84ea8
Added counter assign, greater than and less than annotations
hiraethese 5d8575c
Updated builder for new format of annotations
hiraethese 84d3c05
Added counter NFA union, need to be tested
hiraethese 5c6bea3
Added counter NFA configuration, language check and simple union test
hiraethese 17dc555
Replaced std::variant with classical polymorphism for annotations
hiraethese f91d1d6
Added language emptiness test and simple test, but not working as exp…
hiraethese 9ffc621
Language emptiness test for CNTNFA is commented (fixme)
hiraethese 3b57e94
Changed CounterTest annotation to CounterEqual
hiraethese 557c0a3
Added counter not equal, greater equal and less equal annotations
hiraethese 4470688
Added intersection (product) of counter NFAs and simple intersection …
hiraethese 8c1918b
Added TODO list and comments
ibaturov f2d8a71
Changed the name of Nfa to Cntnfa as it should be
hiraethese 9ec926a
Changed execute to update and test to guard in annotations
hiraethese 755900a
Renamed counters to registers so the counters will be only for Cntnfa…
hiraethese 2d6c587
Changed insert to add to ensure that registers and counters are unique
ibaturov d76fa8e
Changed logic of the shared counters to the correct logic of unique c…
hiraethese 1387732
Changed get type for annotation types to enum class, todo list updated
hiraethese 792e352
Minor changes for TODO list
hiraethese 3e8d648
Allocate space for counter set instead of just reserving space in union
hiraethese 9c75abd
Merge branch 'devel' into cntnfa-merge
hiraethese 3cebc9e
Tests integration changes with namespaces and include changes so we c…
hiraethese 67095e8
Added tests-integration for Cntnfa. Used pragma once! Probably should…
hiraethese db316c8
Added basic job for merged testing of Nfa and Cntnfa and unique timers
hiraethese 276c1fb
Added binary operations merged to tests integration
hiraethese 6aecfde
Added cntnfa benchmark to state the test explosion and intersection f…
ibaturov 802d34a
Added working state explosion benchmark
hiraethese 8e94c88
Removed unnecessary files and renamed cntnfa files in test integrations
hiraethese d6e5bd8
Added test cntnfa single param jobs and renamed state explosion in cn…
hiraethese f4efd9d
Merge branch 'devel' into cntnfa-merge
hiraethese 2d4bced
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese 1ba56a4
Added double param jobs for cntnfa in tests integration
hiraethese af400e1
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese 823a82b
Updated binary operations test for cntnfa and added the number of ite…
hiraethese 00ffb59
Added number of iterations to test on existing benchmarks, changed to…
hiraethese 396cc98
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese 06da4be
Reversed benchmarking to just cntnfa without nfa to generate two sepa…
hiraethese 33a0557
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese b01b20e
Added large sequence benchmark for cntnfa-bench
hiraethese 1ce89c9
Added input and job for large sequence cntnfa benchmark
hiraethese a113f42
Removed large sequence, state explosion test is used instead
hiraethese 6e09fcb
Renamed state explosion files in tests integration
hiraethese c5ef96b
Added working cntnfa-bench
hiraethese c574159
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese 6fd65d3
Merge remote-tracking branch 'upstream' into cntnfa-merge
hiraethese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| 2. Register transducer annotation, trida je podtridou (?) | ||
|
|
||
| 3. Udelat override pro intersection a union (?) | ||
|
|
||
| 6. Predelat na synchronized iterator (?) | ||
|
|
||
| 7. Argumentovat ten test prazdnosti protoze je hodne slozity najit clanek a odkaz na clanek (?) | ||
|
|
||
| 8. Pouzit regex a benchmark na regexovani a opakovat to 50000 krat nebo velmi velke cislo (?) | ||
|
|
||
| 9. Udelat prunik s velkym poctem stavu (?) | ||
|
|
||
| 10. Udelat prunik a test nalezitosti jazyka (?) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| /* algorithms.hh -- Wrapping up algorithms for Cntnfa manipulation which would be otherwise in anonymous namespaces. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "mata/cntnfa/cntnfa.hh" | ||
| #include "mata/simlib/util/binary_relation.hh" | ||
|
|
||
| /** | ||
| * Concrete NFA implementations of algorithms, such as complement, inclusion, or universality checking. | ||
| * | ||
| * This is a separation of the implementation from the interface defined in mata::cntnfa. | ||
| * Note, that in mata::cntnfa interface, there are particular dispatch functions calling | ||
| * these function according to parameters provided by a user. | ||
| * E.g. we can call the following function: `is_universal(aut, alph, {{'algorithm', 'antichains'}})` | ||
| * to check for universality based on antichain-based algorithm. | ||
| * | ||
| * In particular, this includes algorithms for: | ||
| * 1. Complementation, | ||
| * 2. Inclusion, | ||
| * 3. Universality checking, | ||
| * 4. Intersection/concatenation with epsilon transitions, or, | ||
| * 5. Computing relation. | ||
| */ | ||
| namespace mata::cntnfa::algorithms { | ||
|
|
||
| /** | ||
| * Brzozowski minimization of automata (revert -> determinize -> revert -> determinize). | ||
| * @param[in] aut Automaton to be minimized. | ||
| * @return Minimized automaton. | ||
| */ | ||
| Cntnfa minimize_brzozowski(const Cntnfa& aut); | ||
|
|
||
| /** | ||
| * Complement implemented by determization, adding sink state and making automaton complete. Then it adds final states | ||
| * which were non final in the original automaton. | ||
| * @param[in] aut Automaton to be complemented. | ||
| * @param[in] symbols Symbols needed to make the automaton complete. | ||
| * @param[in] minimize_during_determinization Whether the determinized automaton is computed by (brzozowski) | ||
| * minimization. | ||
| * @return Complemented automaton. | ||
| */ | ||
| Cntnfa complement_classical(const Cntnfa& aut, const mata::utils::OrdVector<Symbol>& symbols); | ||
|
|
||
| /** | ||
| * Complement implemented by determization using Brzozowski minimization, adding a sink state and making the automaton | ||
| * complete. Then it swaps final and non-final states. | ||
| * @param[in] aut Automaton to be complemented. | ||
| * @param[in] symbols Symbols needed to make the automaton complete. | ||
| * @return Complemented automaton. | ||
| */ | ||
| Cntnfa complement_brzozowski(const Cntnfa& aut, const mata::utils::OrdVector<Symbol>& symbols); | ||
|
|
||
| /** | ||
| * Inclusion implemented by complementation of bigger automaton, intersecting it with smaller and then it checks | ||
| * emptiness of intersection. | ||
| * @param[in] smaller Automaton which language should be included in the bigger one. | ||
| * @param[in] bigger Automaton which language should include the smaller one. | ||
| * @param[in] alphabet Alphabet of both automata (it is computed automatically, but it is more efficient to set it if | ||
| * you have it). | ||
| * @param[out] cex A potential counterexample word which breaks inclusion | ||
| * @return True if smaller language is included, | ||
| * i.e., if the final intersection of smaller complement of bigger is empty. | ||
| */ | ||
| bool is_included_naive(const Cntnfa& smaller, const Cntnfa& bigger, const Alphabet* alphabet = nullptr, Run* cex = nullptr); | ||
|
|
||
| /** | ||
| * Inclusion implemented by antichain algorithms. | ||
| * @param[in] smaller Automaton which language should be included in the bigger one | ||
| * @param[in] bigger Automaton which language should include the smaller one | ||
| * @param[in] alphabet Alphabet of both automata (not needed for antichain algorithm) | ||
| * @param[out] cex A potential counterexample word which breaks inclusion | ||
| * @return True if smaller language is included, | ||
| * i.e., if the final intersection of smaller complement of bigger is empty. | ||
| */ | ||
| bool is_included_antichains(const Cntnfa& smaller, const Cntnfa& bigger, const Alphabet* alphabet = nullptr, Run* cex = nullptr); | ||
|
|
||
| /** | ||
| * Universality check implemented by checking emptiness of complemented automaton | ||
| * @param[in] aut Automaton which universality is checked | ||
| * @param[in] alphabet Alphabet of the automaton | ||
| * @param[out] cex Counterexample word which eventually breaks the universality | ||
| * @return True if the complemented automaton has non empty language, i.e., the original one is not universal | ||
| */ | ||
| bool is_universal_naive(const Cntnfa& aut, const Alphabet& alphabet, Run* cex); | ||
|
|
||
| /** | ||
| * Universality checking based on subset construction with antichain. | ||
| * @param[in] aut Automaton which universality is checked | ||
| * @param[in] alphabet Alphabet of the automaton | ||
| * @param[out] cex Counterexample word which eventually breaks the universality | ||
| * @return True if the automaton is universal, otherwise false. | ||
| */ | ||
| bool is_universal_antichains(const Cntnfa& aut, const Alphabet& alphabet, Run* cex); | ||
|
|
||
| Simlib::Util::BinaryRelation compute_relation( | ||
| const Cntnfa& aut, | ||
| const ParameterMap& params = {{ "relation", "simulation"}, { "direction", "forward"}}); | ||
|
|
||
| /** | ||
| * @brief Compute product of two NFAs. | ||
| */ | ||
| Cntnfa product_counter_nfas(const Cntnfa& lhs, const Cntnfa& rhs); | ||
|
|
||
| /** | ||
| * @brief Compute product of two NFAs, final condition is to be specified, with a possibility of using multiple epsilons. | ||
| * | ||
| * @param[in] lhs First NFA to compute intersection for. | ||
| * @param[in] rhs Second NFA to compute intersection for. | ||
| * @param[in] first_epsilons The smallest epsilon. | ||
| * @param[in] final_condition The predicate that tells whether a pair of states is final (conjunction for intersection). | ||
| * @param[out] prod_map Can be used to get the mapping of the pairs of the original states to product states. | ||
| * Mostly useless, it is only filled in and returned if !=nullptr, but the algorithm internally uses another data structures, | ||
| * because this one is too slow. | ||
| * @return NFA as a product of NFAs @p lhs and @p rhs with ε-transitions preserved. | ||
| */ | ||
| Cntnfa product(const Cntnfa& lhs, const Cntnfa& 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); | ||
|
|
||
| /** | ||
| * @brief Concatenate two NFAs. | ||
| * | ||
| * Supports epsilon symbols when @p use_epsilon is set to true. | ||
| * @param[in] lhs First automaton to concatenate. | ||
| * @param[in] rhs Second automaton to concatenate. | ||
| * @param[in] epsilon Epsilon to be used co concatenation (provided @p use_epsilon is true) | ||
| * @param[in] use_epsilon Whether to concatenate over epsilon symbol. | ||
| * @param[out] lhs_state_renaming Map mapping lhs states to result states. | ||
| * @param[out] rhs_state_renaming Map mapping rhs states to result states. | ||
| * @return Concatenated automaton. | ||
| */ | ||
| Cntnfa concatenate_eps(const Cntnfa& lhs, const Cntnfa& rhs, const Symbol& epsilon, bool use_epsilon = false, | ||
| StateRenaming* lhs_state_renaming = nullptr, StateRenaming* rhs_state_renaming = nullptr); | ||
|
|
||
| } // namespace mata::cntnfa::algorithms. |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be removed.