https://github.com/gbathie/property_test_regular
Efficient C++ implementation of a property tester for regular expressions/languages.
https://github.com/gbathie/property_test_regular
publication-code regex regular-languages sublinear-algorithms
Last synced: about 2 months ago
JSON representation
Efficient C++ implementation of a property tester for regular expressions/languages.
- Host: GitHub
- URL: https://github.com/gbathie/property_test_regular
- Owner: GBathie
- License: mit
- Created: 2020-08-03T13:48:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-05T16:20:03.000Z (almost 5 years ago)
- Last Synced: 2023-12-11T18:52:25.521Z (over 1 year ago)
- Topics: publication-code, regex, regular-languages, sublinear-algorithms
- Language: C++
- Homepage:
- Size: 84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Property testing of regular languages
Efficient C++ header-contained implementation of a property tester for regular languages
(i.e. sets of words defined by regular expressions), by Gabriel Bathie.
This is part of the work I did during my research internship under the supervision of Tatiana Starikovskaya at ENS Ulm during the summer 2020.
Our publication with details on the analysis of the algorithm can be found online here (not yet available, todo).---
### Usage
Simply include `property_tester.h` in your project, and add `nfa.h` and `property_tester.h` to your include path.
Examples of creation of an NFA and usage of the property testing algorithm can be found in `example.cpp`.
To compile the example, use `make example`.---
### Tests
Here may be found the results of the `tests.cpp` program when compiled and ran on my computer.Results for the NFA for `0^*1^*`:
Results for a random NFA with `10` states:
As expected, the property testing algorithm is much faster than the exact algorithm
when the input is large, and tends to a constant time complexity.
The runtime is not exactly constant because letters that appear in multiple samples
are only queried once. The larger the input is, the less overlapping queries there are (on average),
and therefore the number of queries (and the runtime) increases slightly.To compile the test program, run `make tests`.
Run the resulting `./tests` file, and then run `python generate_graphs.py` to generate graphs as seen above.---
### Warnings
When using functions `Nfa::accepts` an `property_test` on literal strings
(that is characters in between double quotes, e.g. `"Hello world"`),
one must either convert the literals to `std::strings` explicitely
or explicitely call the functions with the template argument `Container = std::string`,
otherwise the trailing null character `\0` is added to the literal, which makes the automaton reject.---