1 / 32

CS490 Presentation: Automata & Language Theory

CS490 Presentation: Automata & Language Theory. Thong Lam Ran Shi. Components of a Formal Language. Symbol Alphabet String Grammar. Components of a Formal Language. Symbol

alaire
Download Presentation

CS490 Presentation: Automata & Language Theory

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Components of a Formal Language • Symbol • Alphabet • String • 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. • 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(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. • 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 intersection of two languages is a language. L = L1 intersect L2 • The complement of a language is a language. L = sigma* - L1 • The difference of two languages is a language. L = L1 - L2

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

  10. Regular Language • Uses: • Symbols/Operations • Concatenation – represented by appending to other symbols, concatenation of a and b is = ab • Union (+) – which represents or a+b = a or b • 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.

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

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

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

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

  15. Finite Automata (cont.) • 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)

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

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

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

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

  20. Context-Free Languages:Pushdown Automaton • Pushdown automaton is a 6-tuple {Q,S,U,P,I,F}, where: • Q is a finite set of states • S is input alphabet • U is stack alphabet • P is transition state • I is initial 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) stack Read input string Transition occurs CU CU can read or write to stack

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

  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) 3) write (a, 2) (5, aab, Ba) 4) read (a ,5) (B, 6) (4, aabb, Ba) 5) scan (b, 4) (5, aabb, B) 6) (6, aabb, )

  24. Context-Free Language:Context-Free Grammars • 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 is the start variable

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

  26. 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.

  27. Turing Machines B B x1 x2 xi xn B B Finite control

  28. Turing machines The Tm we construct will accept the language { 0n1n | 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. 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.

  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. 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 0n1n and accepts.

  30. The formal specification to the TM M is M= ({q0 , q1 , q2 ,q3 ,q4 } , {0,1}, {0,1,X,Y,B}, , q0, B, {q4}) where  is State 0 1 X Y B q0 (q1, X, R) - - (q3, Y,R) - q1 (q1, 0, R) (q2, Y, L) - (q1, Y, R) - q2 (q2, 0, L) - (q0, X, R) (q2, Y, L) - q3 - - - (q3, Y, R) (q4, B, R) 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. • It is undecidable otherwise. • “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. • CS386 notes • Daniel Firpo from spring CS490 • http://www.cs.okstate.edu/~marcin/mp/teach/summer03/5313/3 • http://www.csee.umbc.edu/help/theory/lang_def.shtml

More Related