Finite State Automata

cs.smith.edu

Finite State Automata

Finite State AutomataWe’ve described two different ways in which formal languages can be defined:1. Recursive definitions (5.1 and 8.1)2. Rewrite rules (6.6.2)There’s another way to describe some languages that has great visual appeal: finiteautomata. A finite state automaton (FSA) can be represented by a special sortof diagram mathematicians call a finite labeled digraph. It consists of nodes or states(circles) and edges (arrows) with labels.ababThe language associated with a finite automaton consists of all wffs you can form bybeginning at a starting node (a circle with a blank arrow leading in), then movingaround the diagram in the direction of the arrows, picking up the characters thatlabel the edges (internal arrows), then finally exiting from an exit node (a circlewith a blank arrow leading away). When you move along an arrow, you add thecharacter to your word by appending it on the left. For example, say you start bycoming into the starting circle, move down and then move up,ababthen the wff you are forming will have started outab.


If you then move right and exit,ababthe wff you form will beaab.A different pathababgets youaabab,and yet another pathababgets youbbab.Here’s an FSA for a and b that gives all possible combinations of “a’s” and b’s:”


abAn FSA can have any number of exit nodes but just one starting node. A languagethat can be represented by an FSA is called regular.Why study FSAs? Researchers in linguistics attempt to understand the rules ofnatural languages. Artificial languages have many of the same characteristics. Anyinsight we gain into artificial languages may tell us something about English andother natural languages.Why look at regular languages? Regular languages are especially nice because we canconstruct algorithms to determine important facts about them. Given an FSA, wecan program a computer to tell us what strings of symbols are legitimate sentencesin the language. This is very useful if we are trying to build a machine that cancommunicate. Languages defined by using rewrite rules do not always have theproperty that we can program a computer to recognize legitimate sentences.Here is a particularly shocking example: Suppose we want to know if there are anylegitimate sentences—any at all! Can we program a computer to tell us, given anyset of rewrite rules, if there are legitimate sentences?Exercises:wheeOdd-numberedsolutionsbegin on page ??1. Construct an FSA for the languagewhere the only words are x, yx, yyx,yyyx,... (All ys except for an x atthe end.)2. Find a set of rewrite rules for thelanguage in exercise 1.3. Construct an FSA for the languagewhere the only words are abc, abbc,abbbc, abbbbc,...


4. Find a set of rewrite rules for thelanguage in exercise 3.All but three of the following languagesare regular. Find which are regular andconstruct an FSA for each.5. Consider the language consisting ofnothing but ‘buffalo.’ A wff in thislanguage is any legitimate Englishsentence.6. Consider the language consisting ofjust ✷ and △. A wff in this languageis one where there is exactly one ✷.7! Consider the language consisting ofnothing but ‘bison’ and ‘intimidate.’.A wff in this language is anylegitimate English sentence. Is thislanguage regular? If so, find an FSAfor it.8!! Consider the language consisting ofnothing but left and rightparentheses. A wff in this languageis one where the parentheses arepaired and nested, that is,11. Can you construct an FSA so thatthe legitimate words are exactlya. those words with no two a’s in arow?b. those words with no isolated a’s(e.g., bab is not allowed)?c. those words with at least one a?12. An automaton that allows severalarrows with similar labels to leavethe same node is called anondeterministic finite stateautomaton (NFSA). It is animportant result of formal languagetheory that if a language can berepresented by an NFSA then it canbe represented by an FSA. Constructan FSA that represents the languagedescribed by the following NFSA.baab(), (()), ()(), and ((()()))()are wffs, but((), )(, and ())(()are not.9!! Consider the language consisting ofjust ♥ and ♠. A wff in this languageis one where there are equal numbersof ♥’s and ♠’s.10. Suppose we use only the letter a andb. Can you construct an FSA so thatthe legitimate words are exactlythose words with no a’s?


c. b13. Match each of the following recursivedefinitions...(A) 1. bb is a wff.2. If X is a wff then so is bbX.3. There are no wffs exceptthose guaranteed by rules 1and 2.(B) 1. b is a wff.2. If X is a wff, then so isbbX.3. There are no wffs exceptthose guaranteed by rules 1and 2.(C) 1. bb is a wff.2. If X is a wff, then so is bX.3. There are no wffs exceptthose guaranteed by rules 1and 2....with one of the following FSAs...a.b bb.bbbbb..and with one of the following setsof rewrite rules:α.⋆ → AA → bBB → bAB →β.⋆ → bAA → bAA → bBB →γ.⋆ → bAA → bBB → bAA → b14!!!The language whose only words are:xy, xxyy, xxxyyy, xxxxyyyy,... isnot regular. Can you construct aninfinite state automaton thatgenerates it?b


Answers, some of them9. Not regular.Section 8.7bx1.y11. a.ba3.cbbab.aaabb a bbuffaloc.a5.7. Not regular.buffalo13.A matches to a and γB matches to c and αC matches to b and β

More magazines by this user
Similar magazines