Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 490: Automata and Language Theory Daniel Firpo Spring 2003.

Similar presentations


Presentation on theme: "CS 490: Automata and Language Theory Daniel Firpo Spring 2003."— Presentation transcript:

1 CS 490: Automata and Language Theory Daniel Firpo Spring 2003

2 Regular Languages Finite Automata (also known as the Finite State Machine) Regular Expressions

3 Regular Languages: Finite Automata Formally, a finite automaton is a 5-tuple (Q, Σ, δ, q 0, F), where: Q is a finite set of states, Σ is a finite set called the alphabet (of the automaton), δ : Q x Σ --> Q is the transition function, q 0  Q is the start state, and F  Q is the set of accept states.

4 Regular Languages: Finite Automata Finite Automaton are visually represented as state diagrams. For example: Finite Automaton, M: q1q1 q2q2 q3q3 01 1 0 0,1

5 Regular Languages: Finite Automata Finite Automaton, M: M = (Q, Σ, δ, q 0, F): Q = {q 1, q 2, q 3 }, Σ = {0,1}, δ is described as: 01 –q 1 q 1 q 2 –q 2 q 3 q 2 –q 3 q 2 q 2 q 1 is the start state, And F = {q 2 }. q1q1 q2q2 q3q3 01 1 0 0,1

6 Regular Languages: Finite Automata The type of finite automaton described in the preceding example is a deterministic finite automaton (DFA). An easier model to work with is the nondeterministic finite automaton (NFA).

7 Regular Languages: Finite Automata While in a DFA, every state must have exactly one transition path for each symbol in the automaton’s alphabet, an NFA can have as one, none, or as many transition path as it needs for each symbol in the alphabet. An NFA can also have a transition path(s) for the empty input, ε. DFA’a and NFA’s are equivalent.

8 Regular Languages: Finite Automata Formally, an NFA is a 5-tuple (Q, Σ, δ, q 0, F), where: Q is a finite set of states, Σ is a finite set called the alphabet (of the automaton), δ : Q x Σ ε --> P(Q) is the transition function, q 0  Q is the start state, and F  Q is the set of accept states.

9 q4q4 Regular Languages: Finite Automata The NFA, N: N = (Q, Σ, δ, q 0, F): Q = {q 1, q 2, q 3, q 4 }, Σ = {0,1}, δ is described as: 01 ε –q 1 { q 1 }{q 1,q 2 }Ø –q 2 { q 3 } Ø{q 3 } –q 3 Ø q 2 Ø –q 4 {q 4 }{q 4 } Ø q 1 is the start state, And F = {q 4 }. q1q1 q2q2 0,1 1 q3q3 0, ε 1

10 Regular Languages: Regular Operations: Union: A  B = {x|x  A or x  B}, Concatenation: AB = {xy|x  A and x  B}, Star: A * = {x 1 x 2 …x k |k  0 and each x i  A}. The class of regular languages is closed under the regular operations. That is, if A and B are regular languages, than so is A  B, AB, and A *.

11 Regular Languages: Regular Expressions Formally, we say that R is a regular expression if R is: A, for some a in the alphabet Σ, ε, the empty string, Ø, the empty language, A  B, AB, or A *, Where A and B are regular languages.

12 Regular Languages: Regular Expressions Regular expressions are useful for designing compilers. The syntax of the tokens, the elemental objects in a programming language, such as the variables and constants, can be described by regular expressions. Once this is done, systems generate the lexical analyzer, which processes the input program. Regular expressions and finite automata are equivalent.

13 Context-Free Languages Pushdown automata (PDA) Context-free grammars (CFG)

14 Context-Free Languages: Pushdown Automaton A PDA is very similar to a NFA. The main difference is that a PDA has a stack, which serves to provide additional memory to the automata.

15 Context-Free Languages: Pushdown Automaton Formally, a pushdown automaton is a 6-tuple (Q, Σ, Γ, δ, q 0, F), where: Q is a finite set of states, Σ is a finite set called the alphabet (of the automaton), Γ is the stack alphabet, δ : Q x Σ ε x Γ ε --> P(Q x Γ ε ) is the transition function, q 0  Q is the start state, and F  Q is the set of accept states.

16 q4q4 q3q3 Context-Free Languages: Pushdown Automata The PDA, M: M = (Q, Σ, Γ, δ, q 0, F): Q = {q 1, q 2, q 3, q 4 }, Σ = {0,1}, Γ = {0,$}, δ is described on the next slide, q 1 is the start state, And F = {q 1,q 4 }. q1q1 q2q2 0,ε  0 ε,ε  ε 1,0  ε ε,$  ε

17 Context-Free Languages: Pushdown Automata The PDA, M: δ is described by: q4q4 q3q3 q1q1 q2q2 0,ε  0 ε,ε  ε 1,0  ε ε,$  ε Σ0--1-- ε -- Γ0$ ε 0$ ε 0$ ε q1q1 q 2,$ q2q2 q 2,0q3,εq3,ε q3q3 q3,εq3,ε q4,εq4,ε q4q4

18 Context-Free Languages: Context-Free Grammars Formally, a context-free grammar is a 4- tuple, (V, Σ, R, S), where: V is a finite set of variables, Σ is a finite set of terminals, R is a finite set of rules, and S  V is the start variable.

19 Context-Free Languages: Context-Free Grammars For example, the following grammar: –G = (V, Σ, R, S), where –V = {S,T}, –Σ = {0,1}, –and R, the rules, are S  0S1 | T T  ε Generates strings such as 01, 0011, and 000111. The language of this grammar, L(G), is: {0 n 1 n | n  0}. CFG’s and PDA’s are equivalent.

20 Turing Machines Turing Machines (TM) are similar to PDA’s, but with memory that is unlimited and unrestricted. The Turing Machine uses an infinite tape. The tape head can read and write symbols on the tape. It can also move to the left or right over the tape. Turing machines have accept states and reject states, which take immediate effect.

21 Turing Machines Turing machines are formally defined as a 7-tuple, (Q, Σ, Γ, δ, q 0, q accept, q reject ), where Q is a finite set of states, Σ is the input alphabet, Γ is the tape alphabet, containing the special blank symbol, , where   Γ and Σ  Γ, δ : Q x Γ  Q x Γ x {L,R} is the transition function, q 0  Q is the start state, q accept  Q is the accept state, and q reject  Q is the reject state, where q reject != q accept.

22 Turing Machines An example, the Turing machine, M: q3q3 q1q1 xRxR q5q5 0LxL0LxL q2q2 q5q5 xRxR q reject q accept xRxR RxRRxR RR RR 0,R0,R 0x,R0x,R LL RR 0x,R0x,R 0x0x

23 Turing Machines In this Turing Machine, M = (Q,Σ,Γ,δ,q 0,q accept,q reject ), such that Q = {q 1,q 2,q 3,q 4,q 5,q accept,q reject }, Σ = {0}, Γ = {0,x,  }, δ is described by the state diagram on the previous slide, The start state is q 0, The accept state is q accept, and The reject state is q reject. M decides the language A = {0 2^n | n  0}.

24 Decidability A language is called Turing recognizable if some Turing machine recognizes it. When a Turing machine receives an input, it can either accept, reject, or loop. The machine fails to accept an input that either rejects or loops. A Turing machine that never loops (either accepts or rejects) is called a decider. A decider that recognizes a language is also said to decide the language. A language is decidable if some Turing machine decides it. The TM in the previous example was a decider.

25 Decidability The relationship among the four main classes of languages: Regular Context-free Decidable Turing-recognizable

26 Resource: Sipser, Michael. Introduction to the Theory of Computation. Boston: PWS Publishing Company, 1997.


Download ppt "CS 490: Automata and Language Theory Daniel Firpo Spring 2003."

Similar presentations


Ads by Google