Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST

Similar documents
Lecture 3: Finite Automata

Lecture 10: Synchronous Sequential Circuits Design

Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST

Lecture 4: Finite Automata

Lecture 3: Finite Automata

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.

Chapter 3. Regular grammars

CSE 105 THEORY OF COMPUTATION

ELE2120 Digital Circuits and Systems. Tutorial Note 9

Logic Design II (17.342) Spring Lecture Outline

Finite Automata. Finite Automata

CSE 105 THEORY OF COMPUTATION

Nondeterministic Finite Automata

Chapter 6. Properties of Regular Languages

Introduction to Formal Languages, Automata and Computability p.1/51

(Refer Slide Time: 0:21)

Introduction to Formal Languages, Automata and Computability p.1/42

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Section 1 (closed-book) Total points 30

Foundations of Informatics: a Bridging Course

Author: Vivek Kulkarni ( )

Finite-state machines (FSMs)

Introduction to Computers & Programming

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

Peter Wood. Department of Computer Science and Information Systems Birkbeck, University of London Automata and Formal Languages

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Theory of Computation

Discrete Structures, Final Exam

CPS 220 Theory of Computation Pushdown Automata (PDA)

Harvard CS 121 and CSCI E-207 Lecture 9: Regular Languages Wrap-Up, Context-Free Grammars

Deterministic Finite Automaton (DFA)

CMSC 330: Organization of Programming Languages

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

EE40 Lec 15. Logic Synthesis and Sequential Logic Circuits

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Digital Circuits and Systems

Nondeterministic Finite Automata

Chapter 8. Turing Machine (TMs)

Decision, Computation and Language

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Finite State Machines 2

Sample Test Paper - I

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Context Free Language Properties

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

Computability and Complexity

Kleene Algebras and Algebraic Path Problems

FINITE STATE MACHINES (AUTOMATA)

Theory of Computation (II) Yijia Chen Fudan University

CMSC 330: Organization of Programming Languages. Regular Expressions and Finite Automata

COM364 Automata Theory Lecture Note 2 - Nondeterminism

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal

EEE2135 Digital Logic Design

Chapter Five: Nondeterministic Finite Automata

Nondeterminism and Epsilon Transitions

Algorithms for NLP

Clocked Sequential Circuits UNIT 13 ANALYSIS OF CLOCKED SEQUENTIAL CIRCUITS. Analysis of Clocked Sequential Circuits. Signal Tracing and Timing Charts

CS 275 Automata and Formal Language Theory. Proof of Lemma II Lemma (II )

Part I: Definitions and Properties

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Automata and Languages

Finite State Machine (1A) Young Won Lim 6/9/18

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

CS 154, Lecture 3: DFA NFA, Regular Expressions

Einführung in die Computerlinguistik

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Outline. policies for the first part. with some potential answers... MCS 260 Lecture 10.0 Introduction to Computer Science Jan Verschelde, 9 July 2014

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

Tasks of lexer. CISC 5920: Compiler Construction Chapter 2 Lexical Analysis. Tokens and lexemes. Buffering

Homework. Context Free Languages. Announcements. Before We Start. Languages. Plan for today. Final Exam Dates have been announced.

Computability Theory

Computer Sciences Department

Combinational Logic. By : Ali Mustafa

EECS150 - Digital Design Lecture 23 - FSMs & Counters

ECS 120 Lesson 15 Turing Machines, Pt. 1

Automata Theory (2A) Young Won Lim 5/31/18

11.1 As mentioned in Experiment 10, sequential logic circuits are a type of logic circuit where the output of

Parikh s Theorem and Descriptional Complexity

Memory Elements I. CS31 Pascal Van Hentenryck. CS031 Lecture 6 Page 1

Finite Automata and Formal Languages TMV026/DIT321 LP4 2012

CMSC 330: Organization of Programming Languages

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

Music as a Formal Language

CS 275 Automata and Formal Language Theory. Proof of Lemma II Lemma (II )

Theory of Computation (IX) Yijia Chen Fudan University

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

Lecture 17: Designing Sequential Systems Using Flip Flops

A representation of context-free grammars with the help of finite digraphs

Digital Logic. CS211 Computer Architecture. l Topics. l Transistors (Design & Types) l Logic Gates. l Combinational Circuits.

PSEUDORANDOM BINARY SEQUENCES GENERATOR

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS Pushdown Automata

Theory of Languages and Automata

Automata and Languages

Computers also need devices capable of Storing data and information Performing mathematical operations on such data

Theory Bridge Exam Example Questions

Chapter Two: Finite Automata

Transcription:

Discrete Mathematics CS204: Spring, 2008 Jong C. Park Computer Science Department KAIST

Today s Topics Sequential Circuits and Finite-State Machines Finite-State Automata Languages and Grammars Nondeterministic Finite-State Automata Relationships Between Languages and Automata AUTOMATA, GRAMMARS, AND LANGUAGES Discrete Mathematics, 2008 Computer Science Division, KAIST 2

Sequential Circuits and Finite- State Machines Note We assume that the state changes only at time t = 0, 1, Definitions A unit time delay accepts as input a bit x t at time t and outputs x t-1, the bit received as input at time t 1. The unit time delay is drawn as in Figure 12.1.1. A serial adder accepts as input two binary numbers. Example Serial-Adder Circuit 3

Sequential Circuits and Finite- State Machines Definition A finite-state machine M consists of (a) A finite set I of input symbols. (b) A finite set O of output symbols. (c) A finite set S of states. (d) A next-state function f from S I into S. (e) An output function g from S I into O. (f) An initial state S. We write M = (I, O, S, f, g, ). 4

Sequential Circuits and Finite- Definition State Machines Let M = (I, O, S, f, g, ) be a finite-state machine. The transition diagram of M is a digraph G whose vertices are the members of S. An arrow designates the initial state. A directed edge ( 1, 2 ) exists in G if there exists an input i with f( 1,i) = 2. In this case, if g( 1,i) = o, the edge ( 1, 2 ) is labeled i /o. 5

Sequential Circuits and Finite- Definition State Machines Let M = (I, O, S, f, g, ) be a finite-state machine. An input string for M is a string over I. The string y 1 y n is the output string for M corresponding to the input string = x 1 x n if there exist states 0,..., n S with 0 = i = f( i-1,x i ) for i = 1,..., n; y i = g( i-1,x i ) for i = 1,..., n. 6

Sequential Circuits and Finite- State Machines Examples A Serial-Adder Finite-State Machine The SR Flip-Flop 7

Finite-State Automata Definition A finite-state automaton A = (I, O, S, f, g, ) is a finite-state machine in which the set of output symbols is {0, 1} and where the current state determines the last output. Those states for which the last output was 1 are called accepting states. Note The transition diagram of a finite-state automaton is usually drawn with the accepting states in double circles and the output symbols omitted. 8

Finite-State Automata Examples Draw the transition diagram of the finitestate machine A defined by the table. Draw the transition diagram of the finitestate automaton of Figure 12.2.3 as a transition diagram of a finite-state machine. 9

Finite-State Automata Note As an alternative to the earlier definition, we can regard a finite-state automaton A as consisting of (1) A finite set I of input symbols (2) A finite set S of states (3) A next-state function f from S I into S (4) A subset A of S of accepting states (5) An initial state S. If we use this characterization, we write A = (I, S, f, A, ). 10

Finite-State Automata Example Draw the transition diagram of the finite-state automaton A = (I, S, f, A, ), where I = {a, b}, S = { 0, 1, 2 }, A = { 2 }}, = 0, with f given by the table. 11

Finite-State Automata Definition Let A = (I, S, f, A, ) be a finite-state automaton. Let = x 1 x n be a string over I. If there exist states 0,, n satisfying (a) 0 = (b) f( i-1, x i ) = i for i = 1,, n (c) n A, we say that is accepted by A. The null string is accepted if and only if A. We let Ac(A) denote the set of strings accepted by A and we say that A accepts Ac(A). Let = x 1 x n be a string over I. Define states 0,, n by conditions (a) and (b) above. We call the (directed) path ( 0,, n ) the path representing in A. 12

Finite-State Automata Examples string acceptance Design a finite-state automaton that accepts precisely those strings over {a, b} that contain no a s. Design a finite-state automaton that accepts precisely those strings over {a, b} that contain an odd number of a s. 13

Finite-State Automata 14

Finite-State Automata Definition The finite-state automata A and A are equivalent if Ac(A) = Ac(A ). Example Verify that the two finite-state automata of Figures 12.2.6 and 12.2.8 are equivalent. 15

Languages and Grammars Definition Let A be a finite set. A (formal) language L over A is a subset of A*, the set of all strings over A. Example Let A = {a, b}. The set L of all strings over A containing an odd number of a s is a language over A. L is precisely the set of strings over A accepted by the finite-state automaton of Figure 12.2.7. 16

Languages and Grammars Definition A phrase-structure grammar (or, simply, grammar) G consists of (a) A finite set N of nonterminal symbols (b) A finite set T of terminal symbols where N T = (c) A finite subset P of [(N T)* - T*] (N T)*, called the set of productions (d) A starting symbol N. We write G = (N, T, P, ). Note A production is usually written A B. 17

Languages and Grammars Example Let N = {, S}, T = {a, b}, P = { b, as, S bs, S b}. Then G = (N, T, P, ) is a grammar. 18

Languages and Grammars Definition Let G = (N, T, P, ) be a grammar. If is a production and x y (N T)*, we say that x y is directly derivable from x y and write x y x y. If i (N T)* for i = 1,..., n, and i+1 is directly derivable from i for i = 1,..., n 1, we say that n is derivable from 1 and write 1 n. We call 1 2 n the derivation of n (from 1 ). By convention, any element of (N T)* is derivable from itself. The language generated by G, written L(G), consists of all strings over T derivable from. 19

Languages and Grammars Examples Determine L(G) where G is the grammar of the earlier example. A Grammar for Integers Backus normal form (or Backus-Naur form, BNF) the nonterminal symbols typically begin with < and end with >. the production S T is written S ::= T. Productions of the form S ::= T 1, S ::= T 2,..., S ::= T n may be combined as S ::= T 1 T 2 T n. 20

Languages and Grammars Definition Let G be a grammar and let denote the null string. (a) If every production is of the form A, where, (N T)*, A N, (N T)* - { }, we call G a context-sensitive (or type 1) grammar. (b) If every production is of the form A, where A N, (N T)*, we call G a context-free (or type 2) grammar. (c) If every production is of the form A a or A ab or A, where A, B N, a T, we call G a regular (or type 3) grammar. 21

Languages and Grammars Definition A language L is context-sensitive (respectively, context-free, regular) if there is a context-sensitive (respectively, context-free, regular) grammar G with L = L(G). Definition Grammars G and G are equivalent if L(G) = L(G ). 22

Languages and Grammars Definition A context-free interactive Lindenmayer grammar consists of (a) A finite set N of nonterminal symbols (b) A finite set T of terminal symbols where N T = (c) A finite set P of productions A B, where A N T and B (N T)* (d) A starting symbol N. Note In a context-free interactive Lindenmayer grammar, to derive the string from the string, all symbols in must be replaced simultaneously. 23

Languages and Grammars Definition Let G = (N, T, P, ) be a context-free interactive Lindenmayer grammar. If = x 1 x n and there are productions x i i in P, for i = 1,..., n, we write 1 n and say that 1 n is directly derivable from. If i+1 is directly derivable from i for i = 1,..., n 1, we say that n is derivable from 1 and write 1 n. We call 1 2 n the derivation of n (from 1 ). The language generated by G, written L(G), consists of all strings over T derivable from. 24

Languages and Grammars Example The von Koch Snowflake N = {D} T = {d, +, -} P = { D D-D++D-D D d + + - - 25

Nondeterministic Finite-State Automata Theorem (FSA Regular grammar) Let A be a finite-state automaton given as a transition diagram. Let be the initial state. Let T be the set of input symbols and let N be the set of states. Let P be the set of productions. S xs if there is an edge labeled x from S to S and S if S is an accepting state. Let G be the regular grammar G = (N, T, P, ). Then the set of strings accepted by A is equal to L(G). 26

Nondeterministic Finite-State Example Automata Write the regular grammar given by the finite-state automaton of Figure 12.2.7. 27

Nondeterministic Finite-State Example Automata Construct a finite-state automaton for the regular grammar defined as follows. T = {a, b}, N = {, C} P = { b, ac, C bc, C b} Starting symbol: 28

Nondeterministic Finite-State Definition Automata A nondeterministic finite-state automaton A consists of (a) A finite set I of input symbols (b) A finite set S of states (c) A next-state function f from S I into P(S) (d) A subset A of S of accepting states (e) An initial state S. We write A = (I, S, f, A, ). 29

Nondeterministic Finite-State Automata Definition Let A = (I, S, f, A, ) be a nondeterministic finite-state automaton. The null string is accepted by A if and only if A. If = x 1 x n is a nonnull string over I and there exist states 0,, n satisfying the following conditions: (a) 0 = (b) i f( i-1, x i ) for i = 1,..., n (c) n A, we say that is accepted by A. We let Ac(A) denote the set of strings accepted by A and we say that A accepts Ac(A). 30

Nondeterministic Finite-State Automata If A and A are nondeterministic finite-state automata and Ac(A) = Ac(A ), we say that A and A are equivalent. If = x 1 x n is a string over I and there exist states 0,, n satisfying conditions (a) and (b), we call the path ( 0,, n ) a path representing in A. 31

Nondeterministic Finite-State Automata Theorem (RG Nondeterministic FSA) Let G = (N, T, P, ) be a regular grammar. Let I = T, S = N {F}, where F N T, f(s, x) = {S S xs P} {F S x P}, A = {F} {S S P}. Then the nondeterministic finite-state automaton A = (I, S, f, A, ) accepts precisely the string L(G). 32

Relationships Between Languages Examples and Automata Find a finite-state automaton equivalent to the nondeterministic finite-state automaton of Figure 12.4.2. Find a finite-state automaton equivalent to the nondeterministic finite-state automaton of Figure 12.4.3. 33

Relationships Between Languages and Automata Theorem Let A = (I, S, f, A, ) be a nondeterministic finite-state automaton. Let (a) S = P(S) (b) I = I (c) = { } (d) A = {X S X A } (e) f (X, x) = if X =, S X f(s,x) if X. Then the finite-state automaton A = (I, S, f, A, ) is equivalent to A. 34

Relationships Between Languages Theorem and Automata A language L is regular if and only if there exists a finite-state automaton that accepts precisely the strings in L. 35

Summary Sequential Circuits and Finite-State Machines Finite-State Automata Languages and Grammars Nondeterministic Finite-State Automata Relationships Between Languages and Automata Discrete Mathematics, 2008 Computer Science Division, KAIST 36