csc 473 automata grammars languages 9 29 10
play

CSC 473 Automata, Grammars & Languages 9/29/10 Automata, - PDF document

CSC 473 Automata, Grammars & Languages 9/29/10 Automata, Grammars and Languages Discourse 03 Finite Automata C SC 473 Automata, Grammars & Languages Finite Automata / Switching Theory (CS) / (CE) Boolean operators / Gates


  1. CSC 473 Automata, Grammars & Languages 9/29/10 Automata, Grammars and Languages Discourse 03 Finite Automata C SC 473 Automata, Grammars & Languages Finite Automata / Switching Theory (CS) / (CE) • Boolean operators / Gates (Elem. Switching Ops) x ∧ y x ∨ y x ⊕ y ¬ x x y 0 0 0 0 0 1 0 1 0 1 1 1 0 0 1 1 0 1 1 1 1 0 2 C SC 473 Automata, Grammars & Languages Boolean Functions / Combinatorial Circuits • Circuit � � x x x x 1 2 1 2 x ∨ ∧ z 1 (sum) 1 ¬ � � x x x x 1 2 1 2 x ∧ z 2 (carry) 2 H half adder � x x 1 2 x z 1 (sum) 1 x H H 2 � � ( x x ) x 1 2 3 z 2 (new carry) ∨ x � x x 3 1 2 (old carry) F full adder 3 C SC 473 Automata, Grammars & Languages Lecture 03 1

  2. CSC 473 Automata, Grammars & Languages 9/29/10 Boolean Functions / Comb. Circuits (cont ʼ d) • Table representing F x 1 x 2 x 3 z 1 z 2 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 4 C SC 473 Automata, Grammars & Languages Boolean Functions / Comb. Circuits (cont ʼ d) • Equations representing F = = � � z g x ( ) x x x 1 1 1 2 3 = = � � � � z g x ( ) (( x x ) x ) ( x x ) 2 2 1 2 3 1 2 • General scheme ( n inputs, m outputs) = z g x ( ) = = … … ( , z z , , z ) g x ( , x , , x ) 1 2 m 1 2 n ( g x ( , x , … , x ), … , g x ( , x , … , x )) 1 1 2 n m 1 2 n 5 C SC 473 Automata, Grammars & Languages Finite Automata / Sequential Circuits • Add “memory” elements = delay elements y i + y i ( ) ( 1 ) combinatorial f x z circuit = � � … z i ( ) f x i ( ( ), ( x i 1 ), ( x i 2 ), ) • Finite # of delay elements possible ⇒ ∃ d = � � … z i ( ) f x i ( ( ), ( x i 1 ), x i ( d )) 6 C SC 473 Automata, Grammars & Languages Lecture 03 2

  3. CSC 473 Automata, Grammars & Languages 9/29/10 Finite Automata / Sequential Circuits • Ex: sequential adder: add 2 binary numbers; low x ( 0 ) order bits received first 1001 1 x ( 0 ) 0101 2 1110 • (a) sequential net (circuit): x i ( ) 1 full x i ( ) z i ( ) 2 adder F 1 carry y i + ( 1 ) 1 y i ( ) 1 7 C SC 473 Automata, Grammars & Languages Finite Automata / Sequential Circuits • (b) Next-State & Output Equations: + = � � � � y i ( 1 ) (( ( ) x i x i ( )) y i ( )) ( ( ) x i x i ( )) 1 1 2 1 1 2 = � � z i ( ) x i ( ) x i ( ) y i ( ) 1 1 2 1 = = • (c) Transition Table: state space { 0 ,1 } { , q q } 0 1 � input alphabet ={(00),(01),(10),(11)} � output alphabet ={0,1} next state/output table x ( 00 ) ( 01 ) ( 10 ) ( 11 ) q q q 0 / 0 q 0 / 1 q 0 / 1 q 1 / 0 0 q q 0 / 1 q 1 / 0 q 1 / 0 q 1 / 1 1 8 C SC 473 Automata, Grammars & Languages Finite Automata / Sequential Circuits • (d) State Diagram: ( 01 )/ 0 ( 00 )/ 0 ( 11 )/ 0 ( 11 )/ 1 q q ( 01 )/ 1 1 0 ( 00 )/ 1 ( 10 )/ 1 ( 10 )/ 0 9 C SC 473 Automata, Grammars & Languages Lecture 03 3

  4. CSC 473 Automata, Grammars & Languages 9/29/10 Finite Automata / Sequential Circuits • (e) Finite-State Transducer (Mealy Machine) = � � � M ( , , , , Q q )  A 5-tuple where 0 = Q { q , q } finite set of states 0 1 q start state 0 � = {( 00 ),( 01 ),( 10 ),( 11 )} input alphabet � = { 0 ,1 } output alphabet � � � � � � : Q Q transition/output function � = � = ( ,( q 00 )) ( ,0 q ) ( ,( q 01 )) ( ,1 q ) 0 0 0 0 � = � = ( ,( q 10 )) ( ,1 q ) ( ,( q 11 )) ( ,0 q ) 0 0 0 1 � = ( ,( q 01 )) ( ,0 q ) etc . 1 1 10 C SC 473 Automata, Grammars & Languages General Sequential Network B = { 0 ,1 } δ is a z x boolean 1 1 functio � + n s � � : B n x z m n + � m s B state space = s y B 1 … � y s � = + ( ( ), ( )) y i x i ( ( y i 1 ), ( )) z i � = � ( , q a ) ( , q b ) 11 C SC 473 Automata, Grammars & Languages Three Types of Automata � � a i a � a a a � c c c c n 3 2 1 n 3 2 1 M time transducer a � a a a n 3 2 1 Yes(1) M No(0) recognizer (acceptor) c � c c c n 3 2 1 M Enumerator (generator) 12 C SC 473 Automata, Grammars & Languages Lecture 03 4

  5. CSC 473 Automata, Grammars & Languages 9/29/10 Machines that Recognize • Detection of an “event”, i.e., a pattern in input • Recognition of just those words in some language L • Definition of a language • Ex: detect abab –all non-overlapping occurrences b b a a b a b a b a 13 C SC 473 Automata, Grammars & Languages Ex: C Comments /* … */ � � � = a {,/} • Filter in the lexical scanner empty (transducer) aa : notation � / : / / : a � � � : : � � in : out : � � � : / : � � : a � : a a : / � / : • Recognizer / a � / � � / a 14 C SC 473 Automata, Grammars & Languages Finite Automaton (Finite State Machine, FSA) • Defn 1.5: A (deterministic) finite automaton is a 5-tuple = � � M ( , , , Q q , F ) 0 Q is a finite set, the states • � is a finite set, the alphabet • � � � � : Q Q is the transition function • � q Q is the start state • 0 � F Q is the set of accepting (final) states • = = � � Q { , q q , q } , F • Ex: M ( , , , Q q ) 0 0 1 2 0 � = = { , } a b F { } q 1 a � = � = ( , ) q a q ( , ) q b q q q 0 1 0 2 1 0 b � = � = ( , ) q a q ( , ) q b q 1 2 1 0 M a b � = � = 0 ( , ) q a q ( , ) q b q 2 2 2 2 q 2 a b , 15 C SC 473 Automata, Grammars & Languages Lecture 03 5

  6. CSC 473 Automata, Grammars & Languages 9/29/10 How FA Compute = � � , F • FA is a finite structure—like M ( , , , Q q ) 0 a program—fixed and static • Need to define the behavior of M on input w  Sequence of configurations  Like trace of a program on given data  Dynamic and input-dependent = M w ababa • Ex: start on input Look at sequence 0 of “moves” determined by the transition function: ( q 0 , ababa ) � ( q 1 , baba ) � ( q 0 , aba ) � q 1 , � ) ( q 1 , ba ) � ( q 0 , a ) ( � � ( q 0 , ababa ) � � ( q 1 , � ) Since in accepting state when input exhausted, w is recognized by M 0 16 C SC 473 Automata, Grammars & Languages www.jflap.org JFLAP is a package of graphical tools which can be used as an aid in learning the basic concepts of Formal Languages and Automata Theory. C SC 473 Automata, Grammars & Languages Info on JFLAP • Website http://www.jflap.org/ Downloads  Tutorial  • Lectura (linux) install cd /usr/local/jflap  java -jar JFLAP.jar  • X11 forwarding (graphics) ssh -X lectura  18 C SC 473 Automata, Grammars & Languages Lecture 03 6

  7. CSC 473 Automata, Grammars & Languages 9/29/10 How FA Compute (cont ʼ d) = � � , F • Given a FA M ( , , , Q q ) 0 � � � Q • Defn: configuration of M is an element of ! • Defn: yields in one step (or moves) relation between configurations is defined by ( � q , w ) � � ( q , a ) = � ( q , aw ) � q � � � � � � � a , w , , q q Q where q , � ) (  Notes: is a function, since δ is. Is undefined. � � � � • Defn: yields is the relation  Means “moves in zero or more steps to” q , w ) � � ( ( q , w )  • Defn: A string w is recognized (accepted) by M ⇔ q 0 , w ) � � ( ( � f � F )( f , � ) 19 C SC 473 Automata, Grammars & Languages How FA Compute (cont ʼ d) • Defn: The language recognized (accepted) by M is ( M ) = { L w : M accepts w } = { w :( � f � F )( � � ( f , � ) q 0 , w ) } • Defn 1.16: A language S is regular iff there is some FA � � = that recognizes it, i.e., ( M )[ is a FA M S L M ( )] q 0 , a ) � � ( M q 1 , � ) • Ex: In FA ( 0 � � ( q 1 , � ) ( q 0 , aba ) � i a ) � � ( q 1 , � ) ( q 0 , ( ab ) � L ( M 0 ) = {( i a : i � 0 ab ) } 20 C SC 473 Automata, Grammars & Languages Example: i = make change for i – 30 ¢ & vend coffee • Coin checker for 30¢ coffee. Σ = { n,d,q } d n 0 d 50 5 n q q 10 q 45 n d q 15 40 q n 20 q 35 n d 25 30 n d d 21 C SC 473 Automata, Grammars & Languages Lecture 03 7

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend