Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.

Similar presentations


Presentation on theme: "CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi."— Presentation transcript:

1 CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi

2 Components of a Formal Language Symbol Symbol Alphabet Alphabet String String Grammar Grammar

3 Components of a Formal Language Symbol A character, glyph, mark. An abstract entity that has no meaning by itself, often called uninterpreted. Letters from various alphabets, digits and special characters are the most commonly used symbols.

4 Components of a Formal Language Alphabet A finite set of symbols. An alphabet is often denoted by sigma(Σ), yet can be given any name. B = {0, 1} Says B is an alphabet of two symbols, 0 and 1. C = {a, b, c} Says C is an alphabet of three symbols, a, b and c. Sometimes space and comma are in an alphabet while other times they are meta symbols used for descriptions.

5 Components of a Formal Language String or Word A finite sequence of symbols from an alphabet. 01110 and 111 are strings from the alphabet B above. aaabccc and b are strings from the alphabet C above. A null string is a string with no symbols, usually denoted by epsilon(ε). The null string has length zero. The null string is usually denoted epsilon (ε). Vertical bars around a string indicate the length of a string expressed as a natural number. For example |00100| = 5, |aab| = 3, | epsilon | = 0

6 Components of a Formal Language Grammer A way to define a language by giving a finite set of rules that describe how valid strings may be constructed. Grammer(G) consists of an alphabet of terminals(Σ), variables(V), production rules(P) and a start symbol(S). G = (V, Σ, P, S).

7 Formal Language A set of strings from an alphabet. A set of strings from an alphabet. The set may be empty, finite or infinite. The set may be empty, finite or infinite. L(M) is the notation for a language defined by a machine M. The machine M accepts a certain set of strings, thus a language. L(M) is the notation for a language defined by a machine M. The machine M accepts a certain set of strings, thus a language. L(G) is the notation for a language defined by a grammar G. The grammar G recognizes a certain set of strings, thus a language. L(G) is the notation for a language defined by a grammar G. The grammar G recognizes a certain set of strings, thus a language. M(L) is the notation for a machine that accepts a language. The language L is a certain set of strings. M(L) is the notation for a machine that accepts a language. The language L is a certain set of strings. G(L) is the notation for a grammar that recognizes a language. The language L is a certain set of strings. G(L) is the notation for a grammar that recognizes a language. The language L is a certain set of strings.

8 Formal Languages (cont.) The union of two languages is a language. L = L1 union L2 The union of two languages is a language. L = L1 union L2 The intersection of two languages is a language. L = L1 intersect L2 The intersection of two languages is a language. L = L1 intersect L2 The complement of a language is a language. L = sigma* - L1 The complement of a language is a language. L = sigma* - L1 The difference of two languages is a language. L = L1 - L2 The difference of two languages is a language. L = L1 - L2

9 Regular Language A set of strings from an alphabet. A set of strings from an alphabet. The set may be empty, finite or infinite. The set may be empty, finite or infinite. Must be able to be represented as finite automata Must be able to be represented as finite automata

10 Regular Language Uses: Uses: Symbols/OperationsSymbols/Operations Concatenation – represented by appending to other symbols, concatenation of a and b is = ab Concatenation – represented by appending to other symbols, concatenation of a and b is = ab Union (+) – which represents or a+b = a or b Union (+) – which represents or a+b = a or b Kleene star(*) – represents 0 or more occurances, for example a*b = {b, ab, aab,...} Kleene star(*) – represents 0 or more occurances, for example a*b = {b, ab, aab,...} ? – represents 0 or 1 occurance, for example a? = a or 0. ? – represents 0 or 1 occurance, for example a? = a or 0.

11 Regular Expressions Must be part of a regular language Must be part of a regular language Example: Example: 1+0*011 is a regular expression. 1+0*011 is a regular expression.

12 Finite Automata Finite automata is also known as the finite state machine Finite automata is also known as the finite state machine It is a 5-tuple {Q, , , q 0, F}where It is a 5-tuple {Q, , , q 0, F}where Q is a finite set of states in the machine Q is a finite set of states in the machine  is the input alphabet  is the input alphabet  is the transition from one state to the next state  is the transition from one state to the next state q 0 is the initial state q 0 is the initial state F is the set of all accepting states F is the set of all accepting states

13 Finite Automata (cont.) Finite Automata (cont.) For example: language consist of all strings have even number of 1’s For example: language consist of all strings have even number of 1’s L={, 0, 00…00, 11, 011, 101, 110, 0011, 00…011 …} L={, 0, 00…00, 11, 011, 101, 110, 0011, 00…011 …} even odd 1 1 0 0

14 Finite Automata (cont.) Finite Automaton, M: Finite Automaton, M: M ={Q, , , q 0, F} M ={Q, , , q 0, F} Q={even, odd} Q={even, odd} ={0,1} ={0,1}  is described as  is described as 0 1 0 1 even {even} {odd} even {even} {odd} odd {odd} {even} odd {odd} {even} q 0 =Even q 0 =Even F={even} F={even}

15 Finite Automata (cont.) The type of finite automaton described in the preceding example is a deterministic finite automaton (DFA). The type of finite automaton described in the preceding example is a deterministic finite automaton (DFA). An easer model to work with is the non- deterministic finite automaton (NFA) An easer model to work with is the non- deterministic finite automaton (NFA)

16 Finite automata (cont.) 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. 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, . An NFA can also have a transition path(s) for the empty input, . DFA ‘s and NFA’s are equivalent DFA ‘s and NFA’s are equivalent

17 Finite Automata Example of NFA: Example of NFA: A B C D D 0,10 1 

18 Regular Languages: Finite Automata Finite Automaton, N: Finite Automaton, N: N={Q, , , q 0, F} N={Q, , , q 0, F} Q={A,B,C,D} Q={A,B,C,D} ={0,1} ={0,1}  is described as:  is described as: 0 1  0 1  A {C}  {B} A {C}  {B} B  {C}  B  {C}  C {D} {D}  C {D} {D}  D {D} {D}  D {D} {D}  q 0 = A q 0 = A F={D} F={D}

19 Context-free Languages A set of strings from an alphabet. A set of strings from an alphabet. The set may be empty, finite or infinite. The set may be empty, finite or infinite. Includes a pumping Lemma. Includes a pumping Lemma. Push Down Automata(PDA). Push Down Automata(PDA). Context-free Grammer(CFG). Context-free Grammer(CFG).

20 Context-Free Languages: Pushdown Automaton Pushdown automaton is a 6-tuple {Q,S,U,P,I,F}, where: Pushdown automaton is a 6-tuple {Q,S,U,P,I,F}, where: Q is a finite set of states Q is a finite set of states S is input alphabet S is input alphabet U is stack alphabet U is stack alphabet P is transition state P is transition state I is initial state I is initial state F is final state F is final state

21 Context-Free Languages: Pushdown automata For example, we have a string aabba Input string (read in opposite to the string that we have) Input string (read in opposite to the string that we have) abbaa CU Read input string Transition occurs stack CU can read or write to stack

22 Context-Free Language: Pushdown Automata For example : L = {a n b n | n>0} For example : L = {a n b n | n>0} 16 5 4 2 3 Push B Scan b Scan a Push a Scan b Pop a Pop B

23 Show the configuration sequence on input aabb Q: { 1, 2, 3, 4, 5, 6} (1,, ) S: { a, b} (2,, B) U: { B, a} (3, a, B) I : {1} (2, a, Ba) F: {6} (3, aa, Ba) P: 1) push (B, 2) (2, aa, Baa) 2) scan (a, 3) (b, 4) (4, aab, Baa) 2) scan (a, 3) (b, 4) (4, aab, Baa) 3) write (a, 2) (5, aab, Ba) 3) write (a, 2) (5, aab, Ba) 4) read (a,5) (B, 6) (4, aabb, Ba) 4) read (a,5) (B, 6) (4, aabb, Ba) 5) scan (b, 4) (5, aabb, B) 5) scan (b, 4) (5, aabb, B) 6) (6, aabb, ) 6) (6, aabb, )

24 Context-Free Language: Context-Free Grammars Context-free grammar is a 4-tuple {V, , R,S}, where: Context-free grammar is a 4-tuple {V, , R,S}, where: V is a finite set of variables V is a finite set of variables  is a finite set of terminals  is a finite set of terminals R is a finite set of rules, and R is a finite set of rules, and S is the start variable S is the start variable

25 Context-Free Languages: Context-free grammars Example of CFG Example of CFG S  aSa S  aSa S  bSb S  bSb S  S  S  aSa  aaSaa  aabSbaa  aabbaa S  aSa  aaSaa  aabSbaa  aabbaa L = { ww r : w { a, b} * } L = { ww r : w { a, b} * }

26 Turing Machines Turing machines (TM) are similar to PDA’s, but with memory that is unlimited and unrestricted. Turing machines (TM) are similar to PDA’s, but with memory that is unlimited and unrestricted. The Turing machine uses an infinite tape. 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. 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. Turing machines have accept states and reject states, which take immediate effect.

27 Turing Machines B Bx1x1 x2x2 xixi xnxn BB Finite control

28 Turing machines The Tm we construct will accept the language { 0 n 1 n | n1} The Tm we construct will accept the language { 0 n 1 n | n1} 1. It is given a finite sequence of 0’s and 1’s on its tape, preceded and followed by an infinity of blanks. 1. It is given a finite sequence of 0’s and 1’s on its tape, preceded and followed by an infinity of blanks. 2.The TM will change a 0 to an X and then a 1 to a Y, until all 0’s and 1’s have been matched. 2.The TM will change a 0 to an X and then a 1 to a Y, until all 0’s and 1’s have been matched. 3. Starting at the left end of the input, it repeatedly changes a 0 to an X and moves to the right over whatever 0’s and Y’s it sees, until it comes to a 1. 3. Starting at the left end of the input, it repeatedly changes a 0 to an X and moves to the right over whatever 0’s and Y’s it sees, until it comes to a 1.

29 4. It changes the 1 to a Y, and moves left, over Y’s and 0’s, until it finds an X. At that point, it looks for a 0 immediately to the right, and if it finds one, changes it to X and repeats the process, changing a matching 1 to a Y. 4. It changes the 1 to a Y, and moves left, over Y’s and 0’s, until it finds an X. At that point, it looks for a 0 immediately to the right, and if it finds one, changes it to X and repeats the process, changing a matching 1 to a Y. 5. If the nonblank input is not in 0 * 1 *, then the TM fail to have next move and will die without accepting. 5. If the nonblank input is not in 0 * 1 *, then the TM fail to have next move and will die without accepting. 6. If it finishes changing all the 0’s to X’s on the same round it changes the last 1 to a Y, then it has found its input to be of the form 0 n 1 n and accepts. 6. If it finishes changing all the 0’s to X’s on the same round it changes the last 1 to a Y, then it has found its input to be of the form 0 n 1 n and accepts.

30 The formal specification to the TM M is The formal specification to the TM M is M= ({q 0, q 1, q 2, q 3, q 4 }, {0,1}, {0,1,X,Y,B}, , q 0, B, {q 4 }) where  is M= ({q 0, q 1, q 2, q 3, q 4 }, {0,1}, {0,1,X,Y,B}, , q 0, B, {q 4 }) where  is State 0 1 X Y B State 0 1 X Y B q0 (q1, X, R) - - (q3, Y,R) - q0 (q1, X, R) - - (q3, Y,R) - q1 (q1, 0, R) (q2, Y, L) - (q1, Y, R) - q1 (q1, 0, R) (q2, Y, L) - (q1, Y, R) - q2 (q2, 0, L) - (q0, X, R) (q2, Y, L) - q2 (q2, 0, L) - (q0, X, R) (q2, Y, L) - q3 - - - (q3, Y, R) (q4, B, R) q3 - - - (q3, Y, R) (q4, B, R) q4 - - - - - q4 - - - - - Symbol

31 Decidability A problem is decidable if a program (usually for a Turing Machine) can determine the answer and terminate with a yes or a no in a finite number of steps. A problem is decidable if a program (usually for a Turing Machine) can determine the answer and terminate with a yes or a no in a finite number of steps. It is undecidable otherwise. It is undecidable otherwise. “Halting Problem” describes a problem that cannot produce a result no matter how much time is given. “Halting Problem” describes a problem that cannot produce a result no matter how much time is given.

32 Resource: Sipser, Michael. Introduction to the Theory of Computation. Boston: PWS Publishing Company, 1997. Sipser, Michael. Introduction to the Theory of Computation. Boston: PWS Publishing Company, 1997. CS386 notes CS386 notes Daniel Firpo from spring CS490 Daniel Firpo from spring CS490 http://www.cs.okstate.edu/~marcin/ mp/teach/summer03/5313/3 http://www.cs.okstate.edu/~marcin/ mp/teach/summer03/5313/3 http://www.cs.okstate.edu/~marcin/ mp/teach/summer03/5313/3 http://www.cs.okstate.edu/~marcin/ mp/teach/summer03/5313/3 http://www.csee.umbc.edu/help/the ory/lang_def.shtml http://www.csee.umbc.edu/help/the ory/lang_def.shtml http://www.csee.umbc.edu/help/the ory/lang_def.shtml http://www.csee.umbc.edu/help/the ory/lang_def.shtml


Download ppt "CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi."

Similar presentations


Ads by Google