Formal Definition of Computation. August 28, 2013

Similar documents
Formal Definition of a Finite Automaton. August 26, 2013

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

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Theory of Languages and Automata

September 7, Formal Definition of a Nondeterministic Finite Automaton

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computability and Complexity

CHAPTER 1 Regular Languages. Contents

Finite Automata and Regular languages

Chapter Two: Finite Automata

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Nondeterministic Finite Automata

CISC 4090 Theory of Computation

Chapter Five: Nondeterministic Finite Automata

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

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

Introduction to Languages and Computation

Lecture 3: Nondeterministic Finite Automata

Nondeterminism. September 7, Nondeterminism

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

Nondeterministic Finite Automata

Nondeterministic finite automata

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

Deterministic Finite Automata (DFAs)

Finite Automata. Mahesh Viswanathan

Theory of Computation

Closure under the Regular Operations

Computation Histories

ECS 120 Lesson 15 Turing Machines, Pt. 1

CSC236 Week 11. Larry Zhang

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

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

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs)

Introduction to Computers & Programming

Automata and Computability. Solutions to Exercises

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

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

CS21 Decidability and Tractability

Notes on State Minimization

Automata and Computability. Solutions to Exercises

CSE 105 THEORY OF COMPUTATION

Theory of Computation (II) Yijia Chen Fudan University

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Finite Automata. Seungjin Choi

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

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

CS4026 Formal Models of Computation

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS 455/555: Finite automata

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

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

Theory of Computation

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

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

Takeaway Notes: Finite State Automata

Chapter 3: The Church-Turing Thesis

Automata and Computability

CSCC63 Worksheet Turing Machines

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS 154, Lecture 3: DFA NFA, Regular Expressions

Computer Sciences Department

CS 154 Introduction to Automata and Complexity Theory

Finite State Automata Design

Context-Free Languages

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

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

Closure under the Regular Operations

CS243, Logic and Computation Nondeterministic finite automata

Theory of Computation (I) Yijia Chen Fudan University

CSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman

Decision, Computation and Language

Non-emptiness Testing for TMs

Languages, regular languages, finite automata

Part I: Definitions and Properties

CSE 105 THEORY OF COMPUTATION

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

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

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,

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

CSC236 Week 10. Larry Zhang

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CS21 Decidability and Tractability

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

Theory of computation: initial remarks (Chapter 11)

UNIT-III REGULAR LANGUAGES

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

The Power of One-State Turing Machines

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

Turing Machines Part II

Non-deterministic Finite Automata (NFAs)

CPS 220 Theory of Computation REGULAR LANGUAGES

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

3515ICT: Theory of Computation. Regular languages

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

CSE 105 THEORY OF COMPUTATION

Introduction to Theory of Computing

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

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

Transcription:

August 28, 2013

Computation model The model of computation considered so far is the work performed by a finite automaton Finite automata were described informally, using state diagrams, and formally, as a 5-tuple Informal description is easier to grasp first, but the formal definition is useful for making this notion precise, resolving any ambiguities that may occur in formal description

Formal definition of computation Let M = (Q, Σ, δ, q 0, F ) be a finite automaton and w = w 1 w 2... w n be a string over Σ Then M accepts w if a sequence of states r 0, r 1,..., r n exist in Q such that the following hold: 1. r 0 = q 0 2. δ(r i, w i+1 ) = r i+1 for i = 0, 1,..., n 1 3. r n F

Formal definition of computation Let M = (Q, Σ, δ, q 0, F ) be a finite automaton and w = w 1 w 2... w n be a string over Σ Then M accepts w if a sequence of states r 0, r 1,..., r n exist in Q such that the following hold: 1. r 0 = q 0 2. δ(r i, w i+1 ) = r i+1 for i = 0, 1,..., n 1 3. r n F Condition (1) says that the machine starts its computation in the start state

Formal definition of computation Let M = (Q, Σ, δ, q 0, F ) be a finite automaton and w = w 1 w 2... w n be a string over Σ Then M accepts w if a sequence of states r 0, r 1,..., r n exist in Q such that the following hold: 1. r 0 = q 0 2. δ(r i, w i+1 ) = r i+1 for i = 0, 1,..., n 1 3. r n F Condition (1) says that the machine starts its computation in the start state Condition (2) says that as long as input is available the machine goes from state to state according to its transition function δ

Formal definition of computation Let M = (Q, Σ, δ, q 0, F ) be a finite automaton and w = w 1 w 2... w n be a string over Σ Then M accepts w if a sequence of states r 0, r 1,..., r n exist in Q such that the following hold: 1. r 0 = q 0 2. δ(r i, w i+1 ) = r i+1 for i = 0, 1,..., n 1 3. r n F Condition (1) says that the machine starts its computation in the start state Condition (2) says that as long as input is available the machine goes from state to state according to its transition function δ Condition (3) says that the machine accepts its input if it ends up in an accept state

Formal definition of computation Let M = (Q, Σ, δ, q 0, F ) be a finite automaton and w = w 1 w 2... w n be a string over Σ Then M accepts w if a sequence of states r 0, r 1,..., r n exist in Q such that the following hold: 1. r 0 = q 0 2. δ(r i, w i+1 ) = r i+1 for i = 0, 1,..., n 1 3. r n F Condition (1) says that the machine starts its computation in the start state Condition (2) says that as long as input is available the machine goes from state to state according to its transition function δ Condition (3) says that the machine accepts its input if it ends up in an accept state

Note We say that a machine M recognizes the language A if A = {w M accepts w}

Regular language Definition 1.7 A language is called a regular language if some finite automaton recognizes it

Example computation Take the machine M 5 from Example 1.13 and w = 10 RESET 22 RESET 012 2, RESET q 0 0, RESET 0 q 1 1 2 2 1, RESET 1 q 2 0 Figure 1 : Finite automaton M 5

Running M 5 M 5 accepts w according to the formal definition of computation because the sequence of states it enters when computing on w is q 0, q 1, q 1, q 0, q 2, q 1, q 0, q 0, q 1, q 0 : q 0 is the first state by definition δ(q 0, 1) = q 1,δ(q 1, 0) = q 1 ), δ(q 1, RESET ) = q 0 δ(q 0, 2) = q 2, δ(q 2, 2) = q 1,δ(q 1, RESET ) = q 0 δ(q 0, 0) = q 0,δ(q 0, 1) = q 1,δ(q 1, 2) = q 0

The language L(M 5 ) L(M 5 ) = {w the sum of the symbols in w is 0 modulo 3, except that RESET resets the count to 0} Since M 5 is a finite automaton L(M 5 ) is a regular language

Designing finite automata Whether it be of automata or artwork, design is a creative process Consequently it cannot be reduced to a simple recipe or formula However, for a given design task one can find a particular approach useful; here we consider a useful approach for designing various types of automata

The approach Be yourself the machine you are trying to design! As the machine you try to design, answer the question: how would you go about performing the machine s task? Pretending that you are the machine is a psychological trick that helps engage your whole mind in the design process

Using the approach Suppose that you are given some language and want to design a finite automaton that recognizes it Remember: a language is a set of strings over a given alphabet!

Pretending to be the automaton Pretending that you are the automaton, you receive an input string and must determine whether it belongs to the language

Pretending to be the automaton Pretending that you are the automaton, you receive an input string and must determine whether it belongs to the language You got to see the symbols in the string one by one. After each symbols you must decide whether the string seen so far is in the language.

Pretending to be the automaton Pretending that you are the automaton, you receive an input string and must determine whether it belongs to the language You got to see the symbols in the string one by one. After each symbols you must decide whether the string seen so far is in the language. The reason is that you, like the machine, don t know when the end of the string is coming; so you must always be ready with the answer.

Making decisions In order to make decisions, you have to figure out what you need to remember about string as you are reading it

Making decisions In order to make decisions, you have to figure out what you need to remember about string as you are reading it Bear in mind that as you are pretending to be a finite automaton, you have a finite number of states and thus a finite memory, say a single sheet of paper

Making decisions In order to make decisions, you have to figure out what you need to remember about string as you are reading it Bear in mind that as you are pretending to be a finite automaton, you have a finite number of states and thus a finite memory, say a single sheet of paper Fortunately, you don t need to remember entire input, you only need to remember certain crucial information

Making decisions In order to make decisions, you have to figure out what you need to remember about string as you are reading it Bear in mind that as you are pretending to be a finite automaton, you have a finite number of states and thus a finite memory, say a single sheet of paper Fortunately, you don t need to remember entire input, you only need to remember certain crucial information Which information is crucial depends on the particular language considered

Example design Suppose Σ = {0, 1} and the language consists of all strings with an odd number of 1s. You want to construct a finite automaton E 1 to recognize this language

Constructing the states

Constructing the states Start getting an input string of 0s and 1s symbol by symbol

Constructing the states Start getting an input string of 0s and 1s symbol by symbol Remember whether the number of 1s seen so far is even or odd;

Constructing the states Start getting an input string of 0s and 1s symbol by symbol Remember whether the number of 1s seen so far is even or odd; Represent the information you need as a finite list: (1) even so far, (2) odd so far

Constructing the states Start getting an input string of 0s and 1s symbol by symbol Remember whether the number of 1s seen so far is even or odd; Represent the information you need as a finite list: (1) even so far, (2) odd so far Assign a state to each possibility, Figure 2 Figure 2 : q even q odd The two states q even and q odd

Constructing transitions To construct transitions you need to observe the way of going between possibilities while reading the input Example: the transition to flip state on a 1 and stay put on 0 is shown in Figure 3 0 0 q even q odd 1 1 Figure 3 : Adding the start and accept state

Start state and final states

Start state and final states Set the start state to the state corresponding to the possibility associated with having seen 0 symbols so far (i.e., the empty string ɛ)

Start state and final states Set the start state to the state corresponding to the possibility associated with having seen 0 symbols so far (i.e., the empty string ɛ) In our example this correspond to q even

Start state and final states Set the start state to the state corresponding to the possibility associated with having seen 0 symbols so far (i.e., the empty string ɛ) In our example this correspond to q even Set the accept states to be those corresponding to possibilities where you want to accept the input

Start state and final states Set the start state to the state corresponding to the possibility associated with having seen 0 symbols so far (i.e., the empty string ɛ) In our example this correspond to q even Set the accept states to be those corresponding to possibilities where you want to accept the input In our example this is the set {q odd }

The result The result of the example considered above is in Figure 4 0 0 1 q even q odd 1 Figure 4 : Adding the start and accept state

Example 1.21 This example shows how to design a finite automaton E 2 to recognize the regular language of all strings over the alphabet Σ = {0, 1} that contain the string 001 as a substring Example:

Example 1.21 This example shows how to design a finite automaton E 2 to recognize the regular language of all strings over the alphabet Σ = {0, 1} that contain the string 001 as a substring Example: strings 0010, 1001, 001, 11111110011111 are in that language

Example 1.21 This example shows how to design a finite automaton E 2 to recognize the regular language of all strings over the alphabet Σ = {0, 1} that contain the string 001 as a substring Example: strings 0010, 1001, 001, 11111110011111 are in that language strings 11, 000, 110111 are not in that language

Pretending to be E 2

Pretending to be E 2 As symbols come in, you would initially skip over all 1s

Pretending to be E 2 As symbols come in, you would initially skip over all 1s If you come to a 0, then you note that you may have just seen the first of the three symbols in the pattern 001

Pretending to be E 2 As symbols come in, you would initially skip over all 1s If you come to a 0, then you note that you may have just seen the first of the three symbols in the pattern 001 If after the first 0 you see a 1, then there were too few 0s so you back to skipping over 1s

Pretending to be E 2 As symbols come in, you would initially skip over all 1s If you come to a 0, then you note that you may have just seen the first of the three symbols in the pattern 001 If after the first 0 you see a 1, then there were too few 0s so you back to skipping over 1s If after the first 0 you see another 0 then you should remember that you have seen two symbols of the pattern

Pretending to be E 2 As symbols come in, you would initially skip over all 1s If you come to a 0, then you note that you may have just seen the first of the three symbols in the pattern 001 If after the first 0 you see a 1, then there were too few 0s so you back to skipping over 1s If after the first 0 you see another 0 then you should remember that you have seen two symbols of the pattern Once you have seen two symbols of the pattern you need to scan the input until you see a 1; if you find it, remember that you succeeded to find the pattern and continue reading the input string until the end of string is reached

The list of possibilities

The list of possibilities 1. Haven t see any symbol of the pattern

The list of possibilities 1. Haven t see any symbol of the pattern 2. Have just seen a 0

The list of possibilities 1. Haven t see any symbol of the pattern 2. Have just seen a 0 3. Have just seen 00

The list of possibilities 1. Haven t see any symbol of the pattern 2. Have just seen a 0 3. Have just seen 00 4. Have seen the entire pattern 001

Designing states and transitions

Designing states and transitions Assign the states q, q 0, q 00, q 001 to the four possibilities

Designing states and transitions Assign the states q, q 0, q 00, q 001 to the four possibilities In state q: while reading 1 remain in q, but reading 0 you move to q 0

Designing states and transitions Assign the states q, q 0, q 00, q 001 to the four possibilities In state q: while reading 1 remain in q, but reading 0 you move to q 0 In state q 0 : reading 0 you transit to q 00 but reading 1 you transit to q

Designing states and transitions Assign the states q, q 0, q 00, q 001 to the four possibilities In state q: while reading 1 remain in q, but reading 0 you move to q 0 In state q 0 : reading 0 you transit to q 00 but reading 1 you transit to q In state q 00 : reading 1 you move to q 001 while reading 0 you remain in state q 00

Designing states and transitions Assign the states q, q 0, q 00, q 001 to the four possibilities In state q: while reading 1 remain in q, but reading 0 you move to q 0 In state q 0 : reading 0 you transit to q 00 but reading 1 you transit to q In state q 00 : reading 1 you move to q 001 while reading 0 you remain in state q 00 In state q 001 : whatever you read remain in q 001.

Start and final states Start state is q The only accept state is q 001 The result is in Figure 5 1 0 q q 0 0 1 1 q 00 q 001 Figure 5 : Accepting strings containing 001 0 0, 1