A DFA is a deterministic finite automaton, a simple model of computation. It is one way to model regular languages. Each DFA consists of a finite set of states and a transition function between those states describing how the state of the machine changes in response to new input. DFAs are closely related to regular expressions in the sense that they can be converted into each other. Thus, DFAs are often used to implement regular expression matchers.
Questions tagged [dfa]
569 questions
7
votes
1 answer
can the compiler feasibly calculate a DFA from a regular expression?
In modding a closed-source game I'm modifying the machine code at runtime to jmp into my own code. To do this in a generic manner I'm using pattern matching to find the code locations I want to modify. (The patterns consist only of characters/bytes…

Mr. Wonko
- 690
- 9
- 17
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
1 answer
How do you write a lexer parser where identifiers may begin with keywords?
Suppose you have a language where identifiers might begin with keywords. For example, suppose "case" is a keyword, but "caser" is a valid identifier. Suppose also that the lexer rules can only handle regular expressions. Then it seems that I…

BenRI
- 724
- 6
- 17
7
votes
4 answers
How does "δ:Q×Σ→Q" read in the definition of a DFA (deterministic finite automaton)?
How do you say δ: Q × Σ → Q in English? Describing what × and → mean would also help.

trusktr
- 44,284
- 53
- 191
- 263
7
votes
2 answers
Pumping lemma for regular language
I have a little confusion in checking whether the given language is regular or not using pumping lemma.
Suppose we have to check whether:
L. The language accepting even number of 0's in regular or not?
We know that it is regular because we can…

greenfxpips.com
- 200
- 1
- 3
- 12
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
1 answer
Recursive generic definitions and Stackoverflow in Java
I'm writing an implementation of deterministic finite automata for some research project and there are some arcs which lead to the same state.
I wrote this class for State , but
I wonder why the code produces Stackoverflow:
public class State…

Evgenii.Balai
- 939
- 13
- 30
6
votes
2 answers
How can I simplify token prediction DFA?
Lexer DFA results in "code too large" error
I'm trying to parse Java Server Pages using ANTLR 3.
Java has a limit of 64k for the byte code of a single method, and I keep running into a "code too large" error when compiling the Java source generated…

erickson
- 265,237
- 58
- 395
- 493
6
votes
1 answer
Why is E(dfa) a decidable language?
I don't understand why the Turing Machine T, ACCEPTS when no accept state is marked and rejects when an accept state is marked:
E(dfa) = {| A is a DFA and L(A) = the empty set(don't have the symbol)}
E(dfa) is a decidable language.
Proof: A DFA…

h4x0rjax
- 359
- 1
- 6
- 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
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
2 answers
Deterministic Finite Automaton of Kleene Star
I read that every Non-deterministic Finite Automaton (NFA) can be transferred into a Deterministic Finite Automaton (DFA). Can this be done for kleene star regex, say a*?
Above is the NFA for a*.

Ankit Shubham
- 2,989
- 2
- 36
- 61
5
votes
1 answer
Knuth–Morris–Pratt algorithm DFA based`?
I want to learn how the Knuth–Morris–Pratt algorithm works. I watched this tutorial form the Princeton University https://www.youtube.com/watch?v=iZ93Unvxwtw . In this Video they use a table, with length of the alphabet = number of lines and length…

Asker
- 431
- 5
- 14
5
votes
6 answers
Efficient mass string search problem
The Problem: A large static list of strings is provided. A pattern string comprised of data and wildcard elements (* and ?). The idea is to return all the strings that match the pattern - simple enough.
Current Solution: I'm currently using a linear…
Matthieu N.
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