I'm having trouble figuring out on deriving a regular grammar for a language that is recognised by a Finite Automata. The key issue I'm facing is the confusion between a regular grammar and a context free grammar. I can't seem to distinguish the difference between both of them and i find them very similar in some aspects such as ambiguity.
Could anyone please explain on how to derive a regular grammar for the language recognised by an FA?
When we speak of regular grammars, we might be talking about (strictly) regular grammars or (extended) regular grammars. These distinct concepts correspond more or less exactly to DFAs and to generalized NFAs with empty transitions, respectively.
Furthermore, regular grammars are either right-regular or left-regular. I find right-regular grammars to be altogether easier to think about, but your mileage may vary.
Given a DFA, a (strictly) right-regular grammar can be produced as follows:
The above construction attempts to avoid adding unnecessary empty productions. If we don't mind having lots of empty productions, an alternative is to dispense with step 4 and in step 5, add transitions X := e if and only if X is an accepting state. This has the same effect.
Given a generalized NFA with empty transitions, an (extended) right-regular grammar can be produced as follows:
Basically, as in rici's linked answer, regular grammars are just an alternate notation for the same underlying information as is present in finite automata. This is fundamentally different from, say, regular expressions which are a fundamentally different (however equivalent) notation for representing regular languages.