Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NFA for (a+b)?c

Tags:

regex

nfa

I need NFA for regex

(a+b)?c

As far as I understand, it should contains epsilon from zero node to node before last one (to match string "c", for example).

To check my NFA I use "Regular Expression to NFA Visializaton web service", but graph for my regex on this service does not contain epsilon from zero node.

Is it bug in service, or I misunderstand something?

Thanks!

like image 332
Vitaly Avatar asked Mar 13 '23 15:03

Vitaly


1 Answers

Seems like a bug. If I try (aa*b)?c which should be the same language the NFA looks very different (and correct). Also when I try using a automata library I've develop myself some time ago I get this:

./fatool --in 're:^(a+b)?c$' --out dot:- | dot -Gdpi=70 -Tpng -onfa.png /dev/stdin NFA

The library if you are interested: https://github.com/wader/libfa

like image 195
Mattias Wadman Avatar answered Mar 25 '23 06:03

Mattias Wadman