Questions tagged [nfa]

An NFA is a nondeterministic finite automaton, a mathematical model of computation that decides membership in regular languages.

An NFA is a nondeterministic finite automaton, a mathematical model of computation that decides membership in regular languages.

It is similar to a DFA except that it is nondeterministic, and the machine can be in multiple states simultaneously. Some definitions of NFAs also allow for e-moves, in which the automaton can transition between states on no input at all.

It is known that for every NFA there is also DFA that expect the same language, thus their computation streangh is identical.

310 questions
7
votes
1 answer

How to implement regular expression NFA with character ranges?

When you read such posts as Regex: NFA and Thompson's algorithm everything looks rather straightforward until you realize in real life you need not only direct characters like "7" or "b", but also: [A-Z] [^_] . namely character classes (or ranges).…
greenoldman
  • 16,895
  • 26
  • 119
  • 185
7
votes
3 answers

Why L={wxw^R| w, x belongs to {a,b}^+ } is a regular language

Using pumping lemma, we can easily prove that the language L1 = {WcW^R|W ∈ {a,b}*} is not a regular language. (the alphabet is {a,b,c}; W^R represents the reverse string W) However, If we replace character c with "x"(x ∈ {a,b}+), say, L2 = {WxW^R|…
henry
  • 185
  • 2
  • 2
  • 13
7
votes
3 answers

Design a nondeterministic finite automata in c++ (incorrect output)

I am doing an assignment for simulate a nondeterministic finite automaton, just as I explain in this post. I have this input read from the file tarea4.in: 1 6 8 0 2 2 5 0 0 a 0 1 a 1 1 b 1 2 c 1 3 c 3 4 d 4 4 d 4 5…
novaKid
  • 233
  • 2
  • 4
  • 11
6
votes
1 answer

Representing graphs in clojure

I am trying to learn a bit of clojure by porting a toy NFA regexp matcher. Obviously my main issue is representing and manipulating graphs. I hit a working solution, but my implementation (using gensym to emulate pointers, basically) leaves me with…
Rom1
  • 3,167
  • 2
  • 22
  • 39
6
votes
1 answer

Why can't the Kleene closure construction for an NFA be simplified?

Most sources, such as http://www.cs.may.ie/staff/jpower/Courses/Previous/parsing/node5.html, suggest that the Kleene closure be constructed with 4 nodes. Why can't it be constructed with just 2, as follows?
ackerleytng
  • 416
  • 6
  • 17
6
votes
3 answers

Pause a thread until a method and all the threads inside finish their work?

I'm new to threads and I was wondering how to use them to make an evaluation in a non deterministic finite automaton. I have the method that calls another method: public bool Evaluate2(string s) { accepted = false; ThreadEval(s,…
nightshade
  • 638
  • 5
  • 15
6
votes
5 answers

How to find the intersection of two NFA

In DFA we can do the intersection of two automata by doing the cross product of the states of the two automata and accepting those states that are accepting in both the initial automata. Union is performed similarly. How ever although i can do union…
Aditya Nambiar
  • 806
  • 1
  • 12
  • 22
5
votes
1 answer

Is there an efficient algorithm to decide whether the language accepted by one NFA is a superset of the language accepted by another?

Given two nondeterministic finite automata M1 and M2, is there an efficient algorithm to determine whether the language accepted by M1 is a superset of the language accepted by M2?
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
5
votes
2 answers

How to implement a NFA or DFA based regexp matching algorithm to find all matches?

The matches can be overlapped. But if multiple matches are found starting from a same position, pick the short one. For example, to find regexp parttern "a.*d" in a string "abcabdcd", the answer should be {"abcabd", "abd"}. And "abcabdcd" and…
Rubbish_Oh
  • 155
  • 1
  • 7
5
votes
0 answers

computing the ε-closure of NFA in haskell

I am implementing a nondeterministic finite automaton in Haskell and I am trying to implement the function that calculates the epsilon closure. To this purpose the NFA is implemented as: data Transaction = Transaction { start_state :: Int, …
elena
  • 889
  • 2
  • 11
  • 19
5
votes
1 answer

Convert a NFA to Regular Expression

I found a same question on this website, and the answer was a PDF describing how to convert an NFA to a regex. But this is not working because this method has some conditions: There are transitions going from the initial state to all other states,…
Dr. Programmer
  • 368
  • 1
  • 7
  • 19
5
votes
1 answer

NFA DFA and Regex to Transition Table

I have been looking out for some algorithm that has in input a regular expression or a string and that converts it into an NFA and then a DFA, and that would actually print out the transition table of the corresponding final DFA. I'am thus wondering…
Anoracx
  • 438
  • 7
  • 24
5
votes
1 answer

How can I convert a regex to an NFA?

Are there any modules available in Python to convert a regular expression to corresponding NFA, or do I have to build the code from scratch (by converting the regex from infix to postfix and then implementing Thompson's Algorithm to get the…
RatDon
  • 3,403
  • 8
  • 43
  • 85
5
votes
2 answers

what is glushkov NFA. What is the difference between Glushkov NFA and Thompson NFA?

I saw this term "Glushkov NFA" at http://lambda-the-ultimate.org/node/2064 . Search engines are returning references to articles that use glushkov nfa, but nothing specific about the glushkov nfa itself. What is Glushkov NFA? How different is it…
woodstok
  • 2,704
  • 3
  • 34
  • 50
5
votes
1 answer

drawing minmal DFA for the given regular expression

What is the direct and easy approach to draw minimal DFA, that accepts the same language as of given Regular Expression(RE). I know it can be done by: Regex ---to----► NFA ---to-----► DFA ---to-----► minimized DFA But is there any shortcut way?…
Niraj Rana
  • 83
  • 1
  • 1
  • 4
1
2
3
20 21