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.

287 questions
47
votes
5 answers

DFA vs NFA engines: What is the difference in their capabilities and limitations?

I am looking for a non-technical explanation of the difference between DFA vs NFA engines, based on their capabilities and limitations.
blunders
  • 3,449
  • 10
  • 39
  • 64
27
votes
3 answers

Steps to creating an NFA from a regular expression

I'm having issues 'describing each step' when creating an NFA from a regular expression. The question is as follows: Convert the following regular expression to a non-deterministic finite-state automaton (NFA), clearly describing the steps of the…
kiliki
  • 287
  • 1
  • 4
  • 7
26
votes
6 answers

How are finite automata implemented in code?

How does one implement a dfa or an nfa for that matter in Python code? What are some good ways to do it in python? And are they ever used in real world projects?
user5899005
  • 401
  • 1
  • 4
  • 5
25
votes
2 answers

Library to check if two regular expressions are equal/isomorphic

I need a library which will take in two regular expressions and determine whether they are isomorphic (i.e. match exactly the same set of strings or not) For example a|b is isomorphic to [ab] As I understand it, a regular expression can be converted…
user1255384
  • 303
  • 2
  • 8
16
votes
2 answers

Finding the complement of a DFA?

I am asked to show DFA diagram and RegEx for the complement of the RegEx (00 + 1)*. In the previous problem I had to prove that the complement of a DFA is closed and is a regular expression also, so I know that to convert a DFA, M to the complement,…
Matt Hintzke
  • 6,737
  • 14
  • 47
  • 102
12
votes
1 answer

How to convert NFA to Regular Expression

I knew that converting a regular expression to a NFA, there is a algorithm. But I was wondering if there is a algorithm to convert a NFA to regular expression. If there is, what is it? And if there isn't, I am also wondering if all NFA can convert…
formatjam
  • 249
  • 1
  • 3
  • 13
11
votes
1 answer

NFA/DFA implementation in C#

Does anyone know of any good NFA and DFA implementation in C#, possibly implementing as well conversions between both? What I would like would be to be able to construct a NFA and then convert it automatically to a DFA, but without having to write…
Miguel
  • 3,246
  • 8
  • 34
  • 66
11
votes
5 answers

Efficient algorithm for converting a character set into a nfa/dfa

I'm currently working on a scanner generator. The generator already works fine. But when using character classes the algorithm gets very slow. The scanner generator produces a scanner for UTF8 encoded files. The full range of characters (0x000000…
raisyn
  • 4,230
  • 9
  • 33
  • 52
10
votes
3 answers

A succinct description of NFA to DFA conversion?

Can someone much brighter than I succinctly describe to the SO community the NFA to DFA conversion algorithm? (Preferably in 500 words or less.) I've seen diagrams and lectures that have only served to confuse what I thought I once knew. I'm mostly…
Old McStopher
  • 6,085
  • 9
  • 58
  • 84
9
votes
4 answers

Efficient (basic) regular expression implementation for streaming data

I'm looking for an implementation of regular expression matching that operates on a stream of data -- i.e., it has an API that allows a user to pass in one character at a time and report when a match is found on the stream of characters seen so far.…
8
votes
1 answer

Regular expression that generates a DFA with dead or superfluous states

I'm looking to implement a DFA minimizer in my lexer, but I can't seem to produce a DFA that doesn't look like it's already the minimal DFA for the expression. I'm constructing the DFA from a NFA that is built using thomson construction from a…
Dervall
  • 5,691
  • 2
  • 23
  • 46
8
votes
2 answers

Does Python use NFAs for regular expression evaluation in the re module?

Does anybody know if Python (any version) used NFAs (Non-Deterministic Finite Automata) to evaluate regular expressions or does it use some other mechanism? Please provide links/reference if available.
Johan
  • 1,179
  • 2
  • 14
  • 23
7
votes
1 answer

NFA simulation in Java

I have been given an assignment to simulate an NFA in Java. Now the following regular expression that I have to simulate an NFA for is ab*((b|d)|c*) I think I have too many e-symbols. I was just wondering if the following image below is…
unleashed
  • 887
  • 2
  • 13
  • 34
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
  • 3
  • 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
  • 2,987
  • 2
  • 20
  • 39
1
2 3
19 20