Computational Models: Class 1

Size: px
Start display at page:

Download "Computational Models: Class 1"

Transcription

1 Computational Models: Class 1 Benny Chor School of Computer Science Tel Aviv University October 19, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay Mansour. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

2 Central Computer Science Questions What is a computer? And what is a computation? In the course, we will develop several computational models, of varying computational powers. These models will provide manageable mathematical abstractions, yet capture the essence of computers and computations. We will start with the simplest such model, termed DFA (deterministic finite automata), or FSM (finite state machine, also interpreted as the flying spaghetti monster). Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

3 Class 1: Outline Finite automata and regular languages Regular operations Sipser s book, chapter 1.1 Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

4 Part I Finite Automata Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

5 Example: An One Way Automatic Door This door has 2 states, open and closed. Pads in front and rear of the door provide inputs, and affect the next state. This is illustrated graphically by: front pad rear pad door open when person approaches hold open until person clears don t open when someone standing behind door Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

6 The Automatic Door as DFA REAR BOTH NEITHER closed FRONT open FRONT REAR BOTH NEITHER States: OPEN CLOSED Sensor: FRONT: someone on front pad REAR: someone on rear pad BOTH: someone(s) on both pads NEITHER no one on either pad. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

7 The Automatic Door as DFA A DFA stands for Deterministic Finite Automata REAR BOTH NEITHER closed FRONT open FRONT REAR BOTH NEITHER neither front rear both closed closed open closed closed open closed open open open Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

8 DFA: Informal definition A different machine, M 1 : q 1 q q 2 3 States: q 1, q 2, and q 3. Start state: q 1 (arrow from outside ). Accept state: q 2 (double circle). State transitions: arrows tagged with letters. 0,1 Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

9 DFA: Informal definition (cont.) q 1 q q 2 3 0,1 On an input string M1 begins in start state q 1 after reading each symbol, DFA makes a state transition with matching label. After reading last symbol, DFA produces output: accept if DFA is an accepting state. reject otherwise. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

10 DFA: Informal definition (cont..) q 1 q q 2 3 0,1 What happens on the following input strings: and what happens in general (which strings are accepted by M 1 )?! Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

11 DFA: Informal definition (cont...) q 1 q q 2 3 This DFA accepts All input strings that end with a 1 All input strings that contain at least one 1, and end with an even number of 0 s No other strings We leave it to you to ponder why this is true. 0,1 Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

12 DFA - Formal Definition Definition 1 A deterministic finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q 0, F), where Q is a finite set called the states, Σ is a finite set called the alphabet, δ : Q Σ Q is the transition function, q 0 Q is the start state, and F Q is the set of accept states. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

13 Back to M q 1 q q 2 3 0,1 M 1 = (Q, Σ, δ, q 1, F) where Q = {q 1, q 2, q 3 }, Σ = {0, 1}, the transition function δ is q 1 is the start state F = {q 2 }. 0 1 q 1 q 1 q 2 q 2 q 3 q 2 q 3 q 2 q 2 Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

14 Another Example a s b a q 1 r 1 b b a a b b q 2 r 2 a Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

15 A Formal Model of Computation Definition 2 Let M = (Q, Σ, δ, q 0, F) be a DFA, and let w = w 1 w 2 w n be a string over Σ. We say that M accepts w if there is a sequence of states r 0,..., r n (r i Q) such that r 0 = q 0 δ(r i, w i+1 ) = r i+1, 0 i < n r n F Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

16 Alphabets and Words Definition 3 An alphabet Σ is a finite set of letters. For example: Σ = {a, b, c,..., z} the English alphabet. Σ = {α, β, γ,..., ζ} the Greek alphabet. Σ = {0, 1} the binary alphabet. Σ = {0, 1,..., 9} the digital alphabet. Definition 4 A word (i.e., string) over Σ, is a finite sequence of letters from Σ. The empty word, ε is the word of length 0, which contains no letter. The collection of all strings over Σ is denoted by Σ. For the binary alphabet, ε, 1, 0, , are all members of Σ. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

17 Languages Definition 5 A language over Σ is a (possibly infinite) subset of Σ. Language examples: Modern English. Ancient Greek. All prime numbers, written using digits. A = {w {0, 1} : w has at most seventeen 0 s}. B = {0 n 1 n : n 0}. C = {w {0, 1} : w has an equal number of 0 s and 1 s}. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

18 The language of a DFA Definition 6 L(M), the language of a DFA M, is the set of strings that M accepts. M may accept many strings M accepts only one language. What language does M accept if it accepts no strings? Definition 7 A language L Σ is called regular, if some deterministic finite automaton accepts it. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

19 Determining and Proving the language of a DFA M 1 is the following DFA: q 1 q q 2 3 0,1 Lemma 8 L(M 1 ) = {w10 2k : k 0, w Σ } Proof: We will define 3 languages, L 1, L 2, L 3, whose union equals Σ. We will show that for each string w Σ, if w L i then on input w, M 1 ends in state q i. The proof is by induction on the length of w. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

20 Determining and Proving the language of a DFA, cont. Definition 9 L 1 = {0 k : k 0} L 2 = {w10 2k : k 0, w Σ } L 3 = {w10 2k+1 : k 0, w Σ } First, note that indeed L 1 L 2 L 3 = Σ. Induction basis (length 0): Easy to see that hypothesis holds for ɛ (which is the only word of this length). Induction step: Assume hypothesis holds for words of length j 0, and prove for words of length j + 1. Let x = yσ, where y Σ and σ Σ, be a word of length j + 1 (hence, y = j). We prove the hypothesis for x, separately for each i {1, 2, 3}. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

21 Proving the language of a DFA: the case y L 1 By induction hypothesis, if y L 1 then on input y, M 1 ends in state q 1. y L 1 means it is of the form y = 0 j. Thus x = 0 j+1 or x = 0 j 1. If x = 0 j+1, then x L 1. By the transition function, after reaching state q 1 on input y, M 1 on the input letter 0 stays in state q 1. So in this case indeed on input x, M 1 ends in state q 1. If x = 0 j 1, then x L 2. By the transition function, after reaching state q 1 on input y, M 1 on the input letter 1 moves to state q 2. So in this case indeed on input x, M 1 ends in state q 2. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

22 Proving the language of a DFA: the cases y L 2, y L 3 We leave these cases to you. This is part of assignment 1. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

23 Additional Examples of Regular languages Let Σ = {0, 1}. L odd = {w {0, 1} : w i = 1 (mod 2)} (odd number of 1 s). L 0 1 = {0m 1 n : m, n 0} (a block of consecutive 0s, followed by a block of consecutive 1s). Any finite language. Claim: All the above languages are regular How would you prove this? Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

24 A DFA Class in Python class DFA: current_state = None def init (self, states, alphabet, transition_function, start_state, accept_states): self.states = states self.alphabet = alphabet self.transition_function = transition_function self.start_state = start_state self.accept_states = accept_states self.current_state = start_state return def transition_to_state_with_input(self, input_value): if (self.current_state, input_value) not in \ self.transition_function.keys(): self.current_state = None return else: self.current_state = \ self.transition_function[(self.current_state, input_value)] return modified from Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

25 A DFA Class in Python, cont. def in_accept_state(self): return self.current_state in accept_states def go_to_initial_state(self): self.current_state = self.start_state return def run_with_input_string(self, input_string): self.go_to_initial_state() for input_char in input_string: print(self.current_state,input_char) self.transition_to_state_with_input(input_char) continue if self.current_state is None: return None else: print(self.current_state) return self.in_accept_state() Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

26 Building an Instance of a DFA in Python states = {(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)} alphabet = { 0, 1 } start_state = (0,0) accept_states = {(1,0),(1,1),(1,2),(0,1)} tf = dict() tf[((0,0), 0 )] = (0,0) tf[((0,1), 0 )] = (0,1) tf[((0,2), 0 )] = (0,2) tf[((1,0), 0 )] = (1,0) tf[((1,1), 0 )] = (1,1) tf[((1,2), 0 )] = (1,2) tf[((0,0), 1 )] = (1,1) tf[((0,1), 1 )] = (1,2) tf[((0,2), 1 )] = (1,0) tf[((1,0), 1 )] = (0,1) tf[((1,1), 1 )] = (0,2) tf[((1,2), 1 )] = (0,0) what = DFA(states, alphabet, tf, start_state, accept_states) What is this DFA doing? What language does it accept? Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

27 Running the Instance of the DFA on an Input String >>> inp_string = list( ) >>> print(what.run_with_input_string(inp_string)) (0, 0) 0 (0, 0) 0 (0, 0) 1 (1, 1) 1 (0, 2) 1 (1, 0) 1 (0, 1) 0 (0, 1) 1 (1, 2) 0 (1, 2) 1 (0, 0) 1 (1, 1) 1 (0, 2) 0 (0, 2) 1 (1, 0) True In our Python implementation, the states the machine goes through, and the input letters, are printed. At the end, True/False is printed and returned, depending on the DFA reaching an accept state or not. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

28 Part II Regular Operations Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

29 The regular operations Let A and B be languages. The union operation: A B = {x : x A or x B} The concatenation operation: A B = {xy : x A and y B} The star operation: A = {x 1 x 2... x k : k 0 and each x i A} We ll show that regular languages are closed under the regular operations. Will start today (with union) and continue next week (with concatenation and star). Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

30 The regular operations Examples Let A= {good, bad} and B = {boy, girl}. Union Concatenation A B = {good, bad, boy, girl} A B = {goodboy, goodgirl, badboy, badgirl} Star A = {ε, good, bad, goodgood, goodbad, badbad, badgood,...} Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

31 Closure under union Theorem 10 If A 1 and A 2 are regular languages, then so is A 1 A 2. Approach to Proof: Some DFA M 1 accepts A 1 Some DFA M 2 accepts A 2 Construct DFA M that accepts A 1 A 2. Attempted Proof Idea: First simulate M 1 on the input string, and if M 1 doesn t accept, then simulate M 2. What s wrong with this idea? Fix: Simulate both machines simultaneously on the input string. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

32 Closure Under Union: Correct Proof Suppose M 1 = (Q 1, Σ, δ 1, q 1, F 1 ) accepts L 1, M 2 = (Q 2, Σ, δ 2, q 2, F 2 ) accepts L 2. Define M as follows (M will accept L 1 L 2 ): Q = Q 1 Q 2. Σ is the same. For each (r 1, r 2 ) Q and a Σ, δ((r 1, r 2 ), a) = (δ 1 (r 1, a), δ 2 (r 2, a)) q 0 = (q 1, q 2 ) F = {(r 1, r 2 ): r 1 F 1 or r 2 F 2 }. Formal proof (next slide) (hey, why not choose F = F 1 F 2?) Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

33 Correctness of the construction Claim 11 L(M) = L(M 1 ) L(M 2 ). Specifically, will show Claim 12 If M on input x reaches state (q 1, q 2 ), then M 1 on input x reaches state q 1, and M 2 on input x reaches state q 2. Proof by Induction on the input length. Induction Basis: x = ɛ, x = 0. Trivial. Induction Step: x = yσ, x = i + 1, y = i and σ Σ. Follows from the definition of δ. Completing the proof: On the board. Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

34 What about concatenation? Theorem 13 If L 1, L 2 are regular languages, then so is L 1 L 2. Example: L 1 = {good, bad} and L 2 = {boy, girl}. L 1 L 2 = {goodboy, goodgirl, badboy, badgirl} This is much harder to prove. Idea: Simulate M 1 for a while, then switch to M 2. Problem: But when do you switch? This leads us into non-determinism, but we must wait for next class... Benny Chor (Tel Aviv University) Computational Models: Class 1 October 19, / 34

Computational Models - Lecture 1 1

Computational Models - Lecture 1 1 Computational Models - Lecture 1 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. February 29/ March 02, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames

More information

Critical CS Questions

Critical CS Questions Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Critical CS Questions What is a computer? And What is a Computation? real computers too complex for any

More information

Computational Models #1

Computational Models #1 Computational Models #1 Handout Mode Nachum Dershowitz & Yishay Mansour March 13-15, 2017 Nachum Dershowitz & Yishay Mansour Computational Models #1 March 13-15, 2017 1 / 41 Lecture Outline I Motivation

More information

Time Magazine (1984)

Time Magazine (1984) Time Magazine (1984) Put the right kind of software into a computer, and it will do whatever you want it to. There may be limits on what you can do with the machines themselves, but there are no limits

More information

Non-Deterministic Finite Automata

Non-Deterministic Finite Automata Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 8 Non-Deterministic Finite Automata 0,1 0,1 0 0,ε q q 1 q 2 3 1 q 4 an NFA

More information

CPS 220 Theory of Computation REGULAR LANGUAGES

CPS 220 Theory of Computation REGULAR LANGUAGES CPS 22 Theory of Computation REGULAR LANGUAGES Introduction Model (def) a miniature representation of a thing; sometimes a facsimile Iraq village mockup for the Marines Scientific modelling - the process

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automata (FA or DFA) CHAPTER Regular Languages Contents definitions, examples, designing, regular operations Non-deterministic Finite Automata (NFA) definitions, euivalence of NFAs and DFAs, closure

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10 Regular Languages Andreas Karwath & Malte Helmert 1 Overview Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages

More information

Computational Models: Class 3

Computational Models: Class 3 Computational Models: Class 3 Benny Chor School of Computer Science Tel Aviv University November 2, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

UNIT-III REGULAR LANGUAGES

UNIT-III REGULAR LANGUAGES Syllabus R9 Regulation REGULAR EXPRESSIONS UNIT-III REGULAR LANGUAGES Regular expressions are useful for representing certain sets of strings in an algebraic fashion. In arithmetic we can use the operations

More information

Computational Models - Lecture 5 1

Computational Models - Lecture 5 1 Computational Models - Lecture 5 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 10/22, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Computational Models - Lecture 3 1

Computational Models - Lecture 3 1 Computational Models - Lecture 3 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. March 13/18, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

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

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

Computational Models: Class 5

Computational Models: Class 5 Computational Models: Class 5 Benny Chor School of Computer Science Tel Aviv University March 27, 2019 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

Computational Models - Lecture 3

Computational Models - Lecture 3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover

More information

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 3/8, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Introduction to Languages and Computation

Introduction to Languages and Computation Introduction to Languages and Computation George Voutsadakis 1 1 Mathematics and Computer Science Lake Superior State University LSSU Math 400 George Voutsadakis (LSSU) Languages and Computation July 2014

More information

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner. Tel Aviv University. November 21, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/2/28 Stereotypical computer CISC 49 Theory of Computation Finite state machines & Regular languages Professor Daniel Leeds dleeds@fordham.edu JMH 332 Central processing unit (CPU) performs all the instructions

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,

More information

COM364 Automata Theory Lecture Note 2 - Nondeterminism

COM364 Automata Theory Lecture Note 2 - Nondeterminism COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007. Proofs, Strings, and Finite Automata CS154 Chris Pollett Feb 5, 2007. Outline Proofs and Proof Strategies Strings Finding proofs Example: For every graph G, the sum of the degrees of all the nodes in G

More information

Computational Models - Lecture 3 1

Computational Models - Lecture 3 1 Computational Models - Lecture 3 1 Handout Mode Iftach Haitner. Tel Aviv University. November 14, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Sri vidya college of engineering and technology

Sri vidya college of engineering and technology Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) CS/ECE 374: Algorithms & Models of Computation, Fall 28 Deterministic Finite Automata (DFAs) Lecture 3 September 4, 28 Chandra Chekuri (UIUC) CS/ECE 374 Fall 28 / 33 Part I DFA Introduction Chandra Chekuri

More information

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

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Deterministic Finite Automata (DFAs) Lecture 3 Tuesday, September 5, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 36 Part I DFA Introduction Sariel

More information

Applied Computer Science II Chapter 1 : Regular Languages

Applied Computer Science II Chapter 1 : Regular Languages Applied Computer Science II Chapter 1 : Regular Languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany Overview Deterministic finite automata Regular languages

More information

Theory of Languages and Automata

Theory of Languages and Automata Theory of Languages and Automata Chapter 1- Regular Languages & Finite State Automaton Sharif University of Technology Finite State Automaton We begin with the simplest model of Computation, called finite

More information

Theory of Computation (I) Yijia Chen Fudan University

Theory of Computation (I) Yijia Chen Fudan University Theory of Computation (I) Yijia Chen Fudan University Instructor Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijiachen@fudan.edu.cn Textbook Introduction to the Theory of Computation Michael

More information

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission. CSE 5 Homework Due: Monday October 9, 7 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments in this

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

Homework. Staff. Happy and fruitful New Year. Welcome to CS105. (Happy New Year) שנה טובה. Meeting Times.

Homework. Staff. Happy and fruitful New Year. Welcome to CS105. (Happy New Year) שנה טובה. Meeting Times. Welcome to CS5 and Happy and fruitful ew Year שנה טובה (Happy ew Year) Meeting Times Lectures: Tue Thu 3:3p -4:5p WLH ote: Thu Oct 9 Lecture is canceled there may be a make-up lecture by quarter s end.

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) Algorithms & Models of Computation CS/ECE 374, Spring 29 Deterministic Finite Automata (DFAs) Lecture 3 Tuesday, January 22, 29 L A TEXed: December 27, 28 8:25 Chan, Har-Peled, Hassanieh (UIUC) CS374 Spring

More information

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is, Recall A deterministic finite automaton is a five-tuple where S is a finite set of states, M = (S, Σ, T, s 0, F ) Σ is an alphabet the input alphabet, T : S Σ S is the transition function, s 0 S is the

More information

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

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata. CMSC 330: Organization of Programming Languages Last Lecture Languages Sets of strings Operations on languages Finite Automata Regular expressions Constants Operators Precedence CMSC 330 2 Clarifications

More information

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

September 11, Second Part of Regular Expressions Equivalence with Finite Aut Second Part of Regular Expressions Equivalence with Finite Automata September 11, 2013 Lemma 1.60 If a language is regular then it is specified by a regular expression Proof idea: For a given regular language

More information

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular Expressions Orit Moskovich Gal Rotem Tel Aviv University October 28, 2015 Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular

More information

UNIT-I. Strings, Alphabets, Language and Operations

UNIT-I. Strings, Alphabets, Language and Operations UNIT-I Strings, Alphabets, Language and Operations Strings of characters are fundamental building blocks in computer science. Alphabet is defined as a non empty finite set or nonempty set of symbols. The

More information

Chapter Five: Nondeterministic Finite Automata

Chapter Five: Nondeterministic Finite Automata Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more

More information

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT. Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { {, } } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite

More information

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

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata CS/Math 24: Introduction to Discrete Mathematics 4/2/2 Lecture 23 : Nondeterministic Finite Automata Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last time we designed finite state automata

More information

Equivalence of DFAs and NFAs

Equivalence of DFAs and NFAs CS 172: Computability and Complexity Equivalence of DFAs and NFAs It s a tie! DFA NFA Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: L.von Ahn, L. Blum, M. Blum What we ll do today Prove that DFAs

More information

front pad rear pad door

front pad rear pad door front pad rear pad door REAR BOTH NEITHER closed FRONT open FRONT REAR BOTH NEITHER Think of this as a simple program that outputs one of two values (states) when provided with the current state and an

More information

Computational Models - Lecture 5 1

Computational Models - Lecture 5 1 Computational Models - Lecture 5 1 Handout Mode Iftach Haitner. Tel Aviv University. November 28, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Nachum Dershowitz & Yishay Mansour. Tel Aviv University. May 17 22, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)

More information

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Finite Automata. BİL405 - Automata Theory and Formal Languages 1 Finite Automata BİL405 - Automata Theory and Formal Languages 1 Deterministic Finite Automata (DFA) A Deterministic Finite Automata (DFA) is a quintuple A = (Q,,, q 0, F) 1. Q is a finite set of states

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. May 11/13, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Theory of Computation Lecture 1. Dr. Nahla Belal

Theory of Computation Lecture 1. Dr. Nahla Belal Theory of Computation Lecture 1 Dr. Nahla Belal Book The primary textbook is: Introduction to the Theory of Computation by Michael Sipser. Grading 10%: Weekly Homework. 30%: Two quizzes and one exam. 20%:

More information

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

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata : Organization of Programming Languages Theory of Regular Expressions Finite Automata Previous Course Review {s s defined} means the set of string s such that s is chosen or defined as given s A means

More information

Course 4 Finite Automata/Finite State Machines

Course 4 Finite Automata/Finite State Machines Course 4 Finite Automata/Finite State Machines The structure and the content of the lecture is based on (1) http://www.eecs.wsu.edu/~ananth/cpts317/lectures/index.htm, (2) W. Schreiner Computability and

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. April 18/ May 2, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Computational Models Lecture 5

Computational Models Lecture 5 Computational Models Lecture 5 One More PDAs Example Equivalence of PDAs and CFLs Nondeterminism adds power to PDAs (not in book) Closure Properties of CFLs Algorithmic Aspects of PDAs and CFLs DFAs and

More information

CSCI 2670 Introduction to Theory of Computing

CSCI 2670 Introduction to Theory of Computing CSCI 267 Introduction to Theory of Computing Agenda Last class Reviewed syllabus Reviewed material in Chapter of Sipser Assigned pages Chapter of Sipser Questions? This class Begin Chapter Goal for the

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures Tuesday 10:45 pm - 12:15 pm Instructions Tuesday 12:30

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 6 CHAPTER 2 FINITE AUTOMATA 2. Nondeterministic Finite Automata NFA 3. Finite Automata and Regular Expressions 4. Languages

More information

Finite Automata. Seungjin Choi

Finite Automata. Seungjin Choi Finite Automata Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr 1 / 28 Outline

More information

Closure under the Regular Operations

Closure under the Regular Operations Closure under the Regular Operations Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have

More information

Theory of Computation (II) Yijia Chen Fudan University

Theory of Computation (II) Yijia Chen Fudan University Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest

More information

CSC236 Week 10. Larry Zhang

CSC236 Week 10. Larry Zhang CSC236 Week 10 Larry Zhang 1 Today s Topic Deterministic Finite Automata (DFA) 2 Recap of last week We learned a lot of terminologies alphabet string length of string union concatenation Kleene star language

More information

CS 455/555: Finite automata

CS 455/555: Finite automata CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently

More information

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2 5-25 Great Theoretical Ideas in Computer Science Lecture 4: Deterministic Finite Automaton (DFA), Part 2 January 26th, 27 Formal definition: DFA A deterministic finite automaton (DFA) M =(Q,,,q,F) M is

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures and Instructions 23.10. 3.11. 17.11. 24.11. 1.12. 11.12.

More information

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application Examples of Regular Expressions 1. 0 10, L(0 10 ) = {w w contains exactly a single 1} 2. Σ 1Σ, L(Σ 1Σ ) = {w w contains at least one 1} 3. Σ 001Σ, L(Σ 001Σ ) = {w w contains the string 001 as a substring}

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Deterministic Finite Automata (DFAs) Lecture 3 Tuesday, September 5, 27 Part I DFA Introduction Sariel Har-Peled (UIUC) CS374 Fall 27 / 36 Sariel

More information

Inf2A: Converting from NFAs to DFAs and Closure Properties

Inf2A: Converting from NFAs to DFAs and Closure Properties 1/43 Inf2A: Converting from NFAs to DFAs and Stuart Anderson School of Informatics University of Edinburgh October 13, 2009 Starter Questions 2/43 1 Can you devise a way of testing for any FSM M whether

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

Decision, Computation and Language

Decision, Computation and Language Decision, Computation and Language Non-Deterministic Finite Automata (NFA) Dr. Muhammad S Khan (mskhan@liv.ac.uk) Ashton Building, Room G22 http://www.csc.liv.ac.uk/~khan/comp218 Finite State Automata

More information

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 CMPSCI 250: Introduction to Computation Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 λ-nfa s to NFA s to DFA s Reviewing the Three Models and Kleene s Theorem The Subset

More information

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet: Languages 1 Languages A language is a set of strings String: A sequence of letters Examples: cat, dog, house, Defined over an alphaet: a,, c,, z 2 Alphaets and Strings We will use small alphaets: Strings

More information

Automata Theory, Computability and Complexity

Automata Theory, Computability and Complexity Automata Theory, Computability and Complexity Mridul Aanjaneya Stanford University June 26, 22 Mridul Aanjaneya Automata Theory / 64 Course Staff Instructor: Mridul Aanjaneya Office Hours: 2:PM - 4:PM,

More information

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

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010 University of Virginia - cs3102: Theory of Computation Spring 2010 PS2 - Comments Average: 77.4 (full credit for each question is 100 points) Distribution (of 54 submissions): 90, 12; 80 89, 11; 70-79,

More information

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing

More information

CS 154 Introduction to Automata and Complexity Theory

CS 154 Introduction to Automata and Complexity Theory CS 154 Introduction to Automata and Complexity Theory cs154.stanford.edu 1 INSTRUCTORS & TAs Ryan Williams Cody Murray Lera Nikolaenko Sunny Rajan 2 Textbook 3 Homework / Problem Sets Homework will be

More information

Equivalence of Regular Expressions and FSMs

Equivalence of Regular Expressions and FSMs Equivalence of Regular Expressions and FSMs Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Regular Language Recall that a language

More information

Closure under the Regular Operations

Closure under the Regular Operations September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure

More information

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata Automata and Formal Languages - CM81 Non-Deterministic Finite Automata Andrés Sicard-Ramírez Universidad EAFIT Semester 217-2 Non-Deterministic Finite Automata (NFA) Introduction q i a a q j a q k The

More information

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

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal CSE 3 Lecture 3: Finite State Machines Emina Torlak and Kevin Zatloukal Topics Finite state machines (FSMs) Definition and examples. Finite state machines with output Definition and examples. Finite state

More information

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs CSE : Foundations of Computing Lecture : Finite State Machine Minimization & NFAs State Minimization Many different FSMs (DFAs) for the same problem Take a given FSM and try to reduce its state set by

More information

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F) Outline Nondeterminism Regular expressions Elementary reductions http://www.cs.caltech.edu/~cs20/a October 8, 2002 1 Determistic Finite Automata A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F) Q is a finite

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2018 http://cseweb.ucsd.edu/classes/sp18/cse105-ab/ Today's learning goals Sipser Section 1.1 Prove closure properties of the class of regular languages Apply closure

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Theory of Regular Expressions DFAs and NFAs Reminders Project 1 due Sep. 24 Homework 1 posted Exam 1 on Sep. 25 Exam topics list posted Practice homework

More information

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three

More information

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

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r Syllabus R9 Regulation UNIT-II NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: In the automata theory, a nondeterministic finite automaton (NFA) or nondeterministic finite state machine is a finite

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Design an automaton that recognizes a given language. Specify each of

More information

Finite Automata and Regular languages

Finite Automata and Regular languages Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation 1/19/2016 LECTURE 3 Last time: DFAs and NFAs Operations on languages Today: Nondeterminism Equivalence of NFAs and DFAs Closure properties of regular languages Sofya Raskhodnikova

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY YOU NEED TO PICK UP THE SYLLABUS, THE COURSE SCHEDULE, THE PROJECT INFO SHEET, TODAY S CLASS NOTES

More information