Can you obtain a string from a DFA transition table?

In summary: I was wondering if the DFA can be used in any way to obtain one string (from the set of all possible strings defined by the regular expression)
  • #1
erotavlas
32
0
Taking a regular expression and converting it to a DFA with transition table, can you go backwards? I.e. take one of the rows of the table and determine what input string would be accepted for that row?
 
Technology news on Phys.org
  • #2
If I understand your question correctly,here is my answer:
First you need to convert the DFA to GNFA (generalized nondeterministic finite automata ).A GNFA is actually special type of NFA. It contains only one accept state. There cannot be ingoing arrows to start state and outgoing arrows from accept state. Except from that there should be a transition between any two pair of states. You can look to the internet about GNFA for more information. Then you can reduce the number of states of GNFA to 2. This is possible for any GNFA. In GNFA each transition is characterized by a regular expression. So the final GNFA will have one transition which is your initial regular expression. Asfter that point you can determine the format of the string the machine accepts.
 
Last edited:
  • #3
Will this correspond to one and only one possible string (from the total of all possible permutations of the characters) defined by the regular expression?
 
  • #4
A regular expression actually means a set of strings, so I don't understand what you mean by one possible string. If you are asking is the result a regular expression that can only define the strings that DFA recognizes, the answer is yes. The resulting expression can create one and only one set of strings which the machine recognizes. If you are asking something else I am sorry for talking about a different thing.
 
  • #5
well I was wondering if the DFA can be used in any way to obtain one string (from the set of all possible strings defined by the regular expression)
 
  • #6
So, yes. Since you can obtain the regular expression, you can create a string using that regular expression. Remember that GNFA will give you only the strings that is recognized by corresponding DFA. I hope this is useful.
 
  • #7
No I mean even before obtaining the regular expression. Can anything about the DFA provide you an instance of a string? Does the DFA in any way enumerate all possible string possibilities? Is there anything that does - without having to build all possibilities yourself by iterating over all the permutations of character combinations.
 
  • #8
So you want to enumerate the strings a finite automata matches? Intuitively that should be pretty simple. Of course that set is often infinite, and you get into issues of enumerating infinite sets, but the set should be countably infinite, so it can be done. Do I understand you right?
 
  • #9
Fooality said:
So you want to enumerate the strings a finite automata matches? Intuitively that should be pretty simple. Of course that set is often infinite, and you get into issues of enumerating infinite sets, but the set should be countably infinite, so it can be done. Do I understand you right?

Yes that's right. How is this accomplished using only the finite automata?

Also I realize some regex may represent infinite set of strings, however say we are not dealing with the infinite. Say we pose a restriction on max length that the strings can be. So we only enumerate the strings that are less than or equal to the max length.
 
  • #10
well, its good to visualize the Finite Automaton in terms of a state diagram: labelled circles (s1, s2, ...) connected by arrows representing state transitions, ending either in accept state or reject state. To enumerate all the accepted strings we want a function that walks through each state, forking as needed, and returning on accept. So for regex 'abc' it walks through 4 states a,b,c,accept and outputs on accept. For one like 'a(b|d)c+e' the function will fork for the OR state once, and for infinitely for c+ state. So its a recursive function. Of course you can pass a variable for recursion depth to limit string length.
Unless I am missing something big, that should work it seems.
 
  • #11
Fooality said:
well, its good to visualize the Finite Automaton in terms of a state diagram: labelled circles (s1, s2, ...) connected by arrows representing state transitions, ending either in accept state or reject state. To enumerate all the accepted strings we want a function that walks through each state, forking as needed, and returning on accept. So for regex 'abc' it walks through 4 states a,b,c,accept and outputs on accept. For one like 'a(b|d)c+e' the function will fork for the OR state once, and for infinitely for c+ state. So its a recursive function. Of course you can pass a variable for recursion depth to limit string length.
Unless I am missing something big, that should work it seems.

My question arose from learning about encryption (format preserving) and some people are using regular expressions to encrypt strings, so what they do is define a format using regular expression that the strings must follow, create a DFA or NFA for that regex, 'rank' something about the DFA table (whatever that is) from {0,1,2,...n} encrypt the number that corresponds with the input string to another number in the same set of states {0,1,2,...n}, then obtain an output string from that.

What are they ranking? How is a single string obtained from a value in the ranked set? Are they actually computing all possible combination of characters that match the regex? Or is there some special property of the DFA that magically matches with an input string and can give you an output string without manually calculating all the variations yourself (since you may end up with combinations that don't match the regex without a whole bunch of conditionals and rules to follow)?

Or maybe the DFA is required to actually obtain all the possible strings - because you can't do it easily just by iterating over all possible combination of characters (since you may end up with strings that don't match the regular expression without using complex conditionals and rules)?
 
  • #12
Wow, sounds like interesting stuff you're into! I'm not familiar enough to be really useful, but I can tell you that one can enumerate all the strings matched my an FA, but to pick one takes something extra. I know in ecyption probability of string appearance is important, so maybe that has something to do with the ranking system? A state transition system that includes probabilities is a Markov model... But I am really shooting in the dark here.
 

Related to Can you obtain a string from a DFA transition table?

1. What is a DFA transition table?

A DFA (Deterministic Finite Automaton) transition table is a table that represents the states and transitions of a DFA. It shows all possible combinations of states and inputs, along with the corresponding next state for each combination.

2. Can a string be obtained from a DFA transition table?

Yes, a string can be obtained from a DFA transition table by following the transitions from the initial state to the final state, based on the inputs given in the string. If the final state is an accepting state, then the string is accepted by the DFA.

3. How do you read a DFA transition table?

To read a DFA transition table, start at the initial state and follow the transitions based on the inputs given in the string. Each row represents a state, and each column represents an input symbol. The value in each cell represents the next state that the DFA will transition to when that input is given in that state. Keep following the transitions until you reach the final state.

4. Can a DFA transition table determine if a string is valid?

Yes, a DFA transition table can determine if a string is valid by following the transitions from the initial state to the final state, based on the inputs given in the string. If the final state is an accepting state, then the string is considered valid. If the final state is not an accepting state, then the string is considered invalid.

5. How is a DFA transition table created?

A DFA transition table is created by identifying all possible states of the DFA and all possible inputs. Then, for each state and input combination, the next state is determined based on the transition rules of the DFA. This information is then organized into a table format, with rows representing states and columns representing inputs, to create the DFA transition table.

Similar threads

  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
1
Views
4K
  • Programming and Computer Science
Replies
4
Views
491
  • Programming and Computer Science
2
Replies
55
Views
4K
  • Programming and Computer Science
Replies
16
Views
3K
  • Programming and Computer Science
Replies
7
Views
291
  • Programming and Computer Science
4
Replies
118
Views
7K
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
Back
Top