Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6734e53
New cntnfa folder
hiraethese Jan 1, 2025
7f3d5fe
New cntnfa include folder
hiraethese Jan 2, 2025
bd63612
Includes are changed and cntnfa is now separated from nfa
hiraethese Jan 2, 2025
53ac4b3
Removed unnecessary includes in cntnfa files
hiraethese Jan 2, 2025
73ccf4c
Minor include fix. Namespace for cntnfa is not fixed.
hiraethese Jan 3, 2025
66a2c1a
Fixed namespace errors. Project is working now.
hiraethese Jan 3, 2025
9ec174a
Changed CounterState to AnnotationState
hiraethese Jan 9, 2025
52224b2
Added annotations and counters basic implementation
hiraethese Jan 10, 2025
a03d170
Added counter test and updated implementation of annotations
hiraethese Jan 10, 2025
96e6fa9
Minor changes
hiraethese Jan 10, 2025
ec53c4d
Added simple tests for counter NFA
hiraethese Jan 11, 2025
0639251
Minor changes
hiraethese Jan 11, 2025
a680b5f
Small fixes and code cleaning
hiraethese Jan 11, 2025
b6c2c45
Updated delta for target state
hiraethese Jan 14, 2025
fe3b759
Added cntfa methods for annotations
hiraethese Jan 15, 2025
ce31262
Minor changes
hiraethese Jan 15, 2025
9698508
Added partial cntnfa tests
hiraethese Jan 15, 2025
cf61213
Added constructors for targets in Delta
hiraethese Jan 16, 2025
ef5bcf8
Removed unnecessary methods for annotations
hiraethese Jan 16, 2025
f82a510
Added basic annotation tests
hiraethese Mar 5, 2025
70f1041
Added insert annotation annotation method for annotation collection
hiraethese Mar 5, 2025
57671b4
Updated annotations and counters
hiraethese Mar 6, 2025
1c948b8
Added basic builder tests for CntNfa
hiraethese Mar 15, 2025
85d9906
Added new parser folder for CNTNFA
hiraethese Apr 1, 2025
64e419a
Implemented basic parser for explicit CNTNFA with annotations
hiraethese Apr 2, 2025
6a4effe
Added counter register set as a part of CNTNFA
hiraethese Apr 11, 2025
9cf4b59
Added comments to CNTNFA parser header file
hiraethese Apr 13, 2025
ee749f6
Added convert parsed nfa to CNTNFA function. Need to test.
hiraethese Apr 13, 2025
17bd970
Typo. Changed format of cntnfa-parser header file from .h to .hh
hiraethese Apr 13, 2025
1f3ca1f
Minor change of include error
hiraethese Apr 13, 2025
8251a60
Added empty file for parser
hiraethese Apr 13, 2025
b7077f1
Added parse CNTNFA from string method (same as for file)
hiraethese Apr 13, 2025
5004a29
Removed unnecessary parser
hiraethese Apr 15, 2025
7838627
Updated old parser header file for annotations
hiraethese Apr 15, 2025
6fae8cf
Revert changes, better to keep it as it is
hiraethese Apr 16, 2025
2e385f5
Updated counter register implementation and added new construct metho…
hiraethese Apr 16, 2025
1253958
Implemented construct counter NFA
hiraethese Apr 16, 2025
4b766ea
Added test for empty CNTNFA
hiraethese Apr 19, 2025
f3f33dd
Updated builder for transitions without annotations. Added simple tests
hiraethese Apr 19, 2025
f5726fc
Added tests for CNTNFA with annotations and get_type() for annotations
hiraethese Apr 19, 2025
7c84ea8
Added counter assign, greater than and less than annotations
hiraethese Apr 20, 2025
5d8575c
Updated builder for new format of annotations
hiraethese Apr 20, 2025
84d3c05
Added counter NFA union, need to be tested
hiraethese Apr 21, 2025
5c6bea3
Added counter NFA configuration, language check and simple union test
hiraethese Apr 21, 2025
17dc555
Replaced std::variant with classical polymorphism for annotations
hiraethese Apr 21, 2025
f91d1d6
Added language emptiness test and simple test, but not working as exp…
hiraethese Apr 21, 2025
9ffc621
Language emptiness test for CNTNFA is commented (fixme)
hiraethese Apr 22, 2025
3b57e94
Changed CounterTest annotation to CounterEqual
hiraethese Apr 22, 2025
557c0a3
Added counter not equal, greater equal and less equal annotations
hiraethese Apr 22, 2025
4470688
Added intersection (product) of counter NFAs and simple intersection …
hiraethese Apr 22, 2025
8c1918b
Added TODO list and comments
ibaturov Apr 28, 2025
f2d8a71
Changed the name of Nfa to Cntnfa as it should be
hiraethese Apr 29, 2025
9ec926a
Changed execute to update and test to guard in annotations
hiraethese Apr 29, 2025
755900a
Renamed counters to registers so the counters will be only for Cntnfa…
hiraethese Apr 30, 2025
2d6c587
Changed insert to add to ensure that registers and counters are unique
ibaturov Apr 30, 2025
d76fa8e
Changed logic of the shared counters to the correct logic of unique c…
hiraethese May 1, 2025
1387732
Changed get type for annotation types to enum class, todo list updated
hiraethese May 1, 2025
792e352
Minor changes for TODO list
hiraethese May 1, 2025
3e8d648
Allocate space for counter set instead of just reserving space in union
hiraethese May 1, 2025
9c75abd
Merge branch 'devel' into cntnfa-merge
hiraethese May 1, 2025
3cebc9e
Tests integration changes with namespaces and include changes so we c…
hiraethese May 11, 2025
67095e8
Added tests-integration for Cntnfa. Used pragma once! Probably should…
hiraethese May 11, 2025
db316c8
Added basic job for merged testing of Nfa and Cntnfa and unique timers
hiraethese May 12, 2025
276c1fb
Added binary operations merged to tests integration
hiraethese May 13, 2025
6aecfde
Added cntnfa benchmark to state the test explosion and intersection f…
ibaturov May 13, 2025
802d34a
Added working state explosion benchmark
hiraethese May 13, 2025
8e94c88
Removed unnecessary files and renamed cntnfa files in test integrations
hiraethese May 18, 2025
d6e5bd8
Added test cntnfa single param jobs and renamed state explosion in cn…
hiraethese May 19, 2025
f4efd9d
Merge branch 'devel' into cntnfa-merge
hiraethese May 19, 2025
2d4bced
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese May 19, 2025
1ba56a4
Added double param jobs for cntnfa in tests integration
hiraethese May 19, 2025
af400e1
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese May 19, 2025
823a82b
Updated binary operations test for cntnfa and added the number of ite…
hiraethese May 19, 2025
00ffb59
Added number of iterations to test on existing benchmarks, changed to…
hiraethese May 19, 2025
396cc98
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese May 19, 2025
06da4be
Reversed benchmarking to just cntnfa without nfa to generate two sepa…
hiraethese May 19, 2025
33a0557
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese May 19, 2025
b01b20e
Added large sequence benchmark for cntnfa-bench
hiraethese May 19, 2025
1ce89c9
Added input and job for large sequence cntnfa benchmark
hiraethese May 19, 2025
a113f42
Removed large sequence, state explosion test is used instead
hiraethese May 19, 2025
6e09fcb
Renamed state explosion files in tests integration
hiraethese May 19, 2025
c5ef96b
Added working cntnfa-bench
hiraethese May 20, 2025
c574159
Merge branch 'cntnfa-mata' into cntnfa-merge
hiraethese May 20, 2025
6fd65d3
Merge remote-tracking branch 'upstream' into cntnfa-merge
hiraethese May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/mata/cntnfa/TODO
Copy link
Copy Markdown
Collaborator

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.

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 (?)
135 changes: 135 additions & 0 deletions include/mata/cntnfa/algorithms.hh
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.
Loading
Loading