I'm trying to prove that all NFAs can be converted into ones with one final state, but I'm not sure how to/if I have to deal with the case of 0 final states.
Everything depends upon your definitions, but typically:
The set of accepting states may be empty
Not all states must be reachable from the initial state
Any NFA without accepting states is trivially equivalent to a DFA with two states: the initial, non-accepting state that loops to itself on all inputs; and an unreachable accepting state that loops to itself on all inputs.
Related
Suppose that DFA D is a valid DFA. What would this imply regarding the reachability of its final states from initial states? May I assume this:
$\delta^* (q_0, w) = f$, where $w \in \Sigma$ and $f \in F$
No, you cannot assume this. It's perfectly consistent with the definition of a DFA for there to be states which are unreachable from the starting state. What you can do is start with a DFA and filter it down to just the states reachable from the start state without changing the language of the DFA, though, if you think it would help.
Hope this helps!
as the title suggests I want somebody to help me in coding the conversion of NFA to DFA . I need the pseudocode only . I have tried searching using Google , and I found the whole source code even , however there were little resource to help me for giving me a formal method (in written words,not via picture) for the conversion . This is a homework problem , and I have already passed the due date , so I really need some altruism here .
Thanks.
I've written an article on this subject.
Converting a NFA to a DFA by subset construction
It includes pseudocode on how to do the transformation as well.
Basically the algorithm is, starting with the starting state of the NFA:
Perform closure on the current state set
For each input symbol do the GOTO operation on the closure set.
If the state set you get from the GOTO is not empty
Do a closure of the state set.
If it is a new set of states:
add a transition between the state sets on the input
repeat the entire operation on this new set
Else
add a transition between the state sets on the input
Do this until there are no more sets or transitions added. It's a difficult algorithm to explain, but not very hard if you have the two basic operations CLOSURE and GOTO done.
When we converting from nfa to dfa there may be result like the image below... My question is, is it necessary to write that from state {4} it's going to Zero state? I mean that without showing the input symbol 1 of {4} is the same with picture below right? or no?
It’s a matter of convention. Personally, I prefer not to clutter my DFA with unnecessary states, especially since DFAs obtained via transformation from NFAs tend to become quite complex anyway, and since it’s deterministic we know that any non-displayed transition must be invalid.
However, I’ve experienced that many people in academia teach / use the other convention, and require all transitions to be explicitly shown. When working as a TA (tutor) I’ve actually had a discussion with a professor about this – he wanted us tutors to deduct points on the final tests for missing transitions in DFAs but I convinced him that deducting points for this was unfair.
it is not necessary to write {4}-> 0 transition because the automat is already accepting the word. this transition means only that this is "nothing" meaningful for our solution. but for details, it is useful to give it, to show the whole automaton.
It matters only if you are trying to draw the MinimalFA (MFA).
Actually you can generate infinite number of DFA s from a single NFA, each of which differ in number of states.
If you remove 'Dead States' in the figure,you will get the MFA.
The figure is OK if you just want a DFA
I am looking for an algorithm to convert a Deterministic Finite Automata to Push Down Automata.
Any help appreciated.
Thanks!
The PDA version of DFA would look the same except each state transition also pushes nothing on the stack and pops nothing off the stack.
Since a PDA is an extension of a DFA with just one additional feature : stack.
Because the transition of a PDA is determined by a triple (current state, input, element at the top of the stack) while transition of a DFA is determined by a tuple (current state, input). And the only difference is the element at the top of the stack. You can convert all the transitions of DFA by transforming the tuple to a triple, e (empty string) inserted as the element at the top of the stack
And after changing the state, push e (empty string) to the stack.
I'm answering this old question just in case someone else looks at it.
The conversions of DFA to PDA can be automated easily by just adding a stack. But there could be possible changes to the semantics of the DFA and after you change it that way manually you could end up in a PDA with less number of states. I faced this problem recently. Its somewhat like this,
In a system (not a compiler or anything like that) the code written earlier was written using an DFA due to some reasons. The transitions occur as the user progress through the code using various functions. After some time a new set of transitions functions arrived which can be used in any order. and also the state after any of these new functions can change back to previous state by one of these functions. The only way to solve this using FST was to add a large number of new states to support this behavior which i a huge amount of work. But instead I just changed from DFA to a PDA. The stack keeps track of the transitions very nicely and the problem is solved with far less number of states. Actually i only had to add N number of states where N is the number of new functions that arrived.
I do not know if someone can automate this kind of a process easily. But there you go, just in case someone is curious about it.
The wikipedia article says
Pushdown automata differ from finite
state machines in two ways:
They can use the top of the stack to decide which transition to
take.
They can manipulate the stack as part of performing a transition.
Pushdown automata choose a transition
by indexing a table by input signal,
current state, and the symbol at the
top of the stack. This means that
those three parameters completely
determine the transition path that is
chosen. Finite state machines just
look at the input signal and the
current state: they have no stack to
work with. Pushdown automata add the
stack as a parameter for choice.
...
Pushdown automata are equivalent to
context-free grammars: for every
context-free grammar, there exists a
pushdown automaton such that the
language generated by the grammar is
identical with the language generated
by the automaton, which is easy to
prove. The reverse is true, though
harder to prove: for every pushdown
automaton there exists a context-free
grammar such that the language
generated by the automaton is
identical with the language generated
by the grammar.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 13 years ago.
Improve this question
Although it's true that some
recursive-nameserver configurations
are (sloppily) referred to as
"caching", e.g., by
RHEL/Fedora/CentOS, that's a really
bad name for that function -- because
caching is orthogonal to recursion.
Theoretically, you could write a
nameserver that does recursive service
but doesn't cache its results. (That
would be a bit perverse, and I don't
know of any.) Conversely, nameserver
packages that cache but know nothing
about how to recurse and instead do
less-helpful alternative iterative
service are common: dnsmasq, pdnsd,
etc. ... ...
Above text source: http://linuxgazette.net/170/lan.html
Please explain what does the author means by "caching is orthogonal to recursion" ?
From Wikipedia's definition of orthogonal:
For example, a car has orthogonal
components and controls (e.g.
accelerating the vehicle does not
influence anything else but the
components involved exclusively with
the acceleration function).
The author is saying that whether a nameserver caches is nothing to do with whether it can recurse.
caching is orthogonal to recursion?
Caching doesn't require/imply recursion.
The term "orthogonal" is meant to be interpreted from a mathematical sense loosely has "the things have nothing in common i.e. separate concepts".
It mean it is one feature is independent with the other one. Or have bothe feature have no influence with the other one. So they can be implemented independantly
in a programming point of view, two orthogonal features
do_work(bool feature1, bool feature2)
{
// do common work
if(feature1)
{ //... do this }
// do common work
if(feature2)
{ // do work }
// do common work
}
or: if they are not orthogonal:
you need to do this: ( and it may have case where you cant combine the two feature.
do_work(bool feature1, bool feature2)
{
if(not feature1 and feature 2)
{ //... do this }
else if(feature1 and not feature2)
{ // do work }
// else impossible or different behavior
// etc..
}