Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Fall 2008.

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Deterministic Finite Automata (DFA)
YES-NO machines Finite State Automata as language recognizers.
Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Fall 2009.
Chapter Two: Finite Automata
CS21 Decidability and Tractability
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
CS5371 Theory of Computation
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
1 Languages and Finite Automata or how to talk to machines...
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections: September 1, 2006.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Topics Automata Theory Grammars and Languages Complexities
CSC 361Finite Automata1. CSC 361Finite Automata2 Formal Specification of Languages Generators Grammars Context-free Regular Regular Expressions Recognizers.
Grammars, Languages and Finite-state automata Languages are described by grammars We need an algorithm that takes as input grammar sentence And gives a.
Great Theoretical Ideas in Computer Science.
Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Fall 2011.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd:
CSCI 2670 Introduction to Theory of Computing September 28, 2005.
CSCI 2670 Introduction to Theory of Computing August 24, 2005.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Theory of Languages and Automata
By: Er. Sukhwinder kaur.  What is Automata Theory? What is Automata Theory?  Alphabet and Strings Alphabet and Strings  Empty String Empty String 
Pushdown Automata (PDAs)
Lecture 1 Computation and Languages CS311 Fall 2012.
Great Theoretical Ideas in Computer Science.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 Theory of Computation 計算理論 2 Instructor: 顏嗣鈞 Web: Time: 9:10-12:10 PM, Monday Place: BL.
Deterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.2)
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
using Deterministic Finite Automata & Nondeterministic Finite Automata
Great Theoretical Ideas in Computer Science for Some.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Theory of Computation Automata Theory Dr. Ayman Srour.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Undecidable.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Computation. Introduction We study this course in order to answer the following questions: What are the fundamental capabilities and limitations.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Nondeterminism The Chinese University of Hong Kong Fall 2011
Formal Foundations-II [Theory of Automata]
CSCI 2670 Introduction to Theory of Computing
Lexical analysis Finite Automata
CIS Automata and Formal Languages – Pei Wang
G. Pullaiah College of Engineering and Technology
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Chapter Two: Finite Automata
Chapter Five: Nondeterministic Finite Automata
Deterministic Finite Automaton (DFA)
Pushdown automata The Chinese University of Hong Kong Fall 2011
Lecture One: Automata Theory Amjad Ali
Formal Languages and Automata Theory BODDEDA HARITHA LAKSHMI,
Automata theory and formal languages COS 3112 – AUTOMATA THEORY PRELIM PERIOD WEEK 1 AND 2.
Nondeterminism The Chinese University of Hong Kong Fall 2010
Presentation transcript:

Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Fall 2008

What is automata theory Automata theory is the study of abstract computational devices Abstract devices are (simplified) models of real computations Computations happen everywhere: On your laptop, on your cell phone, in nature, … Why do we need abstract models?

A simple computer BATTERY SWITCH input: switch output: light bulb actions: flip switch states: on, off

A simple “computer” BATTERY SWITCH off on start f f input: switch output: light bulb actions: f for “flip switch” states: on, off bulb is on if and only if there was an odd number of flips

Another “computer” BATTERY off start 1 inputs: switches 1 and 2 actions: 1 for “flip switch 1” actions: 2 for “flip switch 2” states: on, off bulb is on if and only if both switches were flipped an odd number of times off on

A design problem Can you design a circuit where the light is on if and only if all the switches were flipped exactly the same number of times? 4 BATTERY ?

A design problem Such devices are difficult to reason about, because they can be designed in an infinite number of ways By representing them as abstract computational devices, or automata, we will learn how to answer such questions

These devices can model many things They can describe the operation of any “small computer”, like the control component of an alarm clock or a microwave They are also used in lexical analyzers to recognize well formed expressions in programming languages: ab1 is a legal name of a variable in C 5u= is not

Different kinds of automata This was only one example of a computational device, and there are others We will look at different devices, and look at the following questions: –What can a given type of device compute, and what are its limitations? –Is one type of device more powerful than another?

Some devices we will see finite automataDevices with a finite amount of memory. Used to model “small” computers. push-down automata Devices with infinite memory that can be accessed in a restricted way. Used to model parsers, etc. Turing MachinesDevices with infinite memory. Used to model any computer. time-bounded Turing Machines Infinite memory, but bounded running time. Used to model any computer program that runs in a “reasonable” amount of time.

Some highlights of the course Finite automata –We will understand what kinds of things a device with finite memory can do, and what it cannot do –Introduce simulation: the ability of one device to “imitate” another device –Introduce nondeterminism: the ability of a device to make arbitrary choices Push-down automata –These devices are related to grammars, which describe the structure of programming (and natural) languages

Some highlights of the course Turing Machines –This is a general model of a computer, capturing anything we could ever hope to compute –Surprisingly, there are many things that we cannot compute, for example: –It seems that you should be able to tell just by looking at the program, but it is impossible to do! Write a program that, given the code of another program in C, tells if this program ever outputs the word “ hello ”

Some highlights of the course Time-bounded Turing Machines –Many problems are possible to solve on a computer in principle, but take too much time in practice –Traveling salesman: Given a list of cities, find the shortest way to visit them and come back home –Easy in principle: Try the cities in every possible order –Hard in practice: For 100 cities, this would take 100+ years even on the fastest computer! Hong Kong Beijing Shanghai Xian Guangzhou Chengdu

Preliminaries of automata theory How do we formalize the question First, we need a formal way of describing the problems that we are interested in solving Can device A solve problem B?

Problems Examples of problems we will consider –Given a word s, does it contain the subword “ fool ”? –Given a number n, is it divisible by 7? –Given a pair of words s and t, are they the same? –Given an expression with brackets, e.g. (()()), does every left bracket match with a subsequent right bracket? All of these have “yes/no” answers. There are other types of problems, that ask “Find this” or “How many of that” but we won’t look at those.

Alphabets and strings A common way to talk about words, number, pairs of words, etc. is by representing them as strings To define strings, we start with an alphabet Examples An alphabet is a finite set of symbols.  1 = {a, b, c, d, …, z} : the set of letters in English  2 = {0, 1, …, 9} : the set of (base 10) digits  3 = {a, b, …, z, #} : the set of letters plus the special symbol #  4 = { (, ) } : the set of open and closed brackets

Strings The empty string will be denoted by  Examples A string over alphabet  is a finite sequence of symbols in . abfbz is a string over  1 = {a, b, c, d, …, z} 9021 is a string over  2 = {0, 1, …, 9} ab#bc is a string over  3 = {a, b, …, z, #} ))()(() is a string over  4 = { (, ) }

Languages Languages can be used to describe problems with “yes/no” answers, for example: A language is a set of strings over an alphabet. L 1 = The set of all strings over  1 that contain the substring “fool” L 2 = The set of all strings over  2 that are divisible by 7 ={7, 14, 21, …} L 3 = The set of all strings of the form s#s where s is any string over {a, b, …, z} L 4 = The set of all strings over  4 where every ( can be matched with a subsequent )

Finite Automata

Example of a finite automaton There are states off and on, the automaton starts in off and tries to reach the “good state” on What sequences of f s lead to the good state? Answer: {f, fff, fffff, …} = {f n : n is odd } This is an example of a deterministic finite automaton over alphabet {f} off on f f

Deterministic finite automata A deterministic finite automaton (DFA) is a 5-tuple (Q, , , q 0, F) where – Q is a finite set of states –  is an alphabet –  : Q ×  → Q is a transition function – q 0  Q is the initial state – F  Q is a set of accepting states (or final states). In diagrams, the accepting states will be denoted by double loops

Example q0q0 q1q1 q2q ,11 alphabet  = {0, 1} start state Q = {q 0, q 1, q 2 } initial state q 0 accepting states F = {q 0, q 1 } states inputs 0 1 q0q0 q1q1 q2q2 q0q0 q1q1 q2q2 q2q2 q2q2 q1q1 transition function 

Language of a DFA The language of a DFA (Q, , , q 0, F) is the set of all strings over  that, starting from q 0 and following the transitions as the string is read left to right, will reach some accepting state. Language of M is {f, fff, fffff, …} = {f n : n is odd } off on f f M:M:

q0q0 q1q1 q0q0 q1q1 q0q0 q1q1 q2q ,11 What are the languages of these DFAs? Examples

Construct a DFA that accepts the language L = {010, 1} (  = {0, 1} )

Examples Construct a DFA that accepts the language Answer L = {010, 1} (  = {0, 1} ) qq q0q0 q1q1 q 01 q 010 q die 0,

Examples Construct a DFA over alphabet {0, 1} that accepts all strings that end in 101

Examples Construct a DFA over alphabet {0, 1} that accepts all strings that end in 101 Hint: The DFA must “remember” the last 3 bits of the string it is reading

Examples 0 1 … … … … qq qq qq q  q  q  q  q  q  q  q  Construct a DFA over alphabet {0, 1} that accepts all strings that end in 101 Sketch of answer: