1.2 Three Basic Concepts Languages
start variables Grammars Let us see a grammar for English. Typically, we are told “a sentence can Consist of a noun phrase followed by a predicate”. We can write this grammar as follows: Furthermore, we have From this grammar, we can produce the sentence like “a boy runs”. variables productions We assume V and T are nonempty and disjoint terminal symbols
Production rules are the heart of a grammar. We let them be of the form * *
* *
Chapter 2 Finite Automata Control unit … Input file... Storage Output Automata Deterministic automata: each move is uniquely determined. Nondeterministic automata: the moves are not uniquely determined. An automata is called an accepter if its output response is limited to “yes” or “no”. An automata is called a transducer if it is capable of producing strings of symbols as output. Current configuration ( current state,input and storage ) Next configuration ( Next state,input and storage ) MOVE ( using Transition function)
2.1 Deterministic Finite Accepters Deterministic accepters and transition graphs Definition 2.1 A deterministic finite accepter or dfa is defined by the quintuple Control unit (transition function δ) … Input file Initial state Control unit (transition function δ) … Input file State
Control unit (transition function δ) … Input file Initial state Control unit (transition function δ) … Input file State Control unit (transition function δ) … Input file State
Transition graphs Example 2.1 The above transition graph represents the dfa It accepts 01, 101,0111,11001,…. But not 00, 100,1100,…. Initial vertex Final vertex Transition function:
Definition 2.1 A deterministic finite accepter or dfa is
Example 2.2 Consider the dfa in the following transition graph. Solution: Trap state Example 2.3 Find a dfa that recognizes the set of all strings on a b a,b a b b Trap state Solution:
Example 2.4 Find a dfa that recognizes the set of all strings on {0,1}, except those containing the substring , ,1 or
Definition 2.3 A language L is called regular if and only if there exists some deterministic finite accepter M such that L = L(M). Example 2.5 Show that language L={awa: w is regular. a a a 0 q b b a,b b Example 2.6 Let L be the language in Example 2.5. Show that is regular. 0 q a a a b b a,b b a a a b b