Finite Automata and Formal Languages



Similar documents
Introduction to Automata Theory. Reading: Chapter 1

Turing Machines: An Introduction

CAs and Turing Machines. The Basis for Universal Computation

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Regular Languages and Finite Automata

Introduction to Theory of Computation

Reading 13 : Finite State Automata and Regular Expressions

The Halting Problem is Undecidable

Computability Theory

THEORY of COMPUTATION

Notes on Complexity Theory Last updated: August, Lecture 1

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Computer Science Theory. From the course description:

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Automata and Formal Languages

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

6.080/6.089 GITCS Feb 12, Lecture 3

Regular Expressions and Automata using Haskell

Complexity Classes P and NP

3515ICT Theory of Computation Turing Machines

CS 301 Course Information

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Properties of Stabilizing Computations

Informatique Fondamentale IMA S8

Overview of E0222: Automata and Computability

Model 2.4 Faculty member + student

Computational complexity theory

Computer Architecture Syllabus of Qualifying Examination

NP-Completeness and Cook s Theorem

Introduction to computer science

Course Manual Automata & Complexity 2015

Automata and Computability. Solutions to Exercises

T Reactive Systems: Introduction and Finite State Automata

the recursion-tree method

CS5310 Algorithms 3 credit hours 2 hours lecture and 2 hours recitation every week

CS5236 Advanced Automata Theory

Universal Turing Machine: A Model for all Computational Problems

Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008.

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

Universality in the theory of algorithms and computer science

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

24 Uses of Turing Machines

Fast nondeterministic recognition of context-free languages using two queues

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

Computational Models Lecture 8, Spring 2009

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

The Model Checker SPIN

Handout #1: Mathematical Reasoning

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

NP-complete? NP-hard? Some Foundations of Complexity. Prof. Sven Hartmann Clausthal University of Technology Department of Informatics

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

MATH 22. THE FUNDAMENTAL THEOREM of ARITHMETIC. Lecture R: 10/30/2003

Finite Automata and Regular Languages

The Little Man Computer

(Refer Slide Time: 2:03)

Introduction to Turing Machines

CS 341: Foundations of Computer Science II elearning Section Syllabus, Spring 2015

Regular Languages and Finite State Machines

Graph Theory Problems and Solutions

Formal Verification of Software

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Genetic programming with regular expressions

Pushdown Automata. International PhD School in Formal Languages and Applications Rovira i Virgili University Tarragona, Spain

Division of Mathematical Sciences

Lecture 2: Universality

FINITE STATE AND TURING MACHINES

Models of Sequential Computation

Specification and Analysis of Contracts Lecture 1 Introduction

CSC 373: Algorithm Design and Analysis Lecture 16

Lecture 11: Tail Recursion; Continuations

Datavetenskapligt Program (kandidat) Computer Science Programme (master)

Quantum and Non-deterministic computers facing NP-completeness

Guide to the MSCS Program Sheet

How To Understand The Relation Between Simplicity And Probability In Computer Science

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

Lecture 1. Basic Concepts of Set Theory, Functions and Relations

COMPUTER SCIENCE STUDENTS NEED ADEQUATE MATHEMATICAL BACKGROUND

Introduction to Logic in Computer Science: Autumn 2006

Lecture 8: Synchronous Digital Systems

Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar

03 - Lexical Analysis

School of Computer Science

Reliably computing cellular automaton, in 1-sparse noise

Lecture 2: Regular Languages [Fa 14]

Department of Computer Science

Turing Machines, Busy Beavers, and Big Questions about Computing

Guide to the MSCS Program Sheet

To download the script for the listening go to:

Midterm Practice Problems

How To Understand The Theory Of Computer Science

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Programming Languages

An Innocent Investigation

Module Catalogue for the Bachelor Program in Computational Linguistics at the University of Heidelberg

Turing Machines, Part I

Algorithmic Software Verification

DEGREE PLAN INSTRUCTIONS FOR COMPUTER ENGINEERING

Molecular Computing Athabasca Hall Sept. 30, 2013

Transcription:

Finite Automata and Formal Languages TMV026/DIT321 LP4 2011 Ana Bove Lecture 1 March 21st 2011 Course Organisation Overview of the Course Overview of today s lecture: Course Organisation Level: This course is a bachelor course. Lectures: Mondays 13.15 15 in HA2 and Tuesdays 10 11:45 in HC3 Extra lecture on the first week: Thursday 10 11:45 in HA3. Ana Bove, bove@chalmers.se Exercise Sessions: Thursdays 13.15 15 in EB VERY important!! Willard Rafnsson, willard.rafnsson@chalmers.se Exams: May 27th and August 26th. No books or written help during the exam. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 1

Course Organisation (Cont.) Assignments: There will be non-obligatory weekly assignments which will generate bonus points valid ONLY on the exams during 2011. Each assignment will be up to 10 pts. If a student has collected n pts in assignments, this will correspond to n/10 points in the exam. Exams are usually 60 points. Write your name and personal number when you submit an assignment. How to submit? On paper or by email. See the web page of the course. Note: Be aware that assignments are part of the examination of the course. Hence, they should be done individually! Standard procedure will be followed if copied solutions are detected. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 2 Course Organisation (Cont.) Book: Introduction to Automata Theory, Languages, and Computation, by Hopcroft, Motwani and Ullman. Addison-Wesley. Both second or third edition are fine. We will cover chapters 1 to 7 and a bit of chapter 8 (if times allows). Wikipedia: http://en.wikipedia.org/wiki/ Web Page: http://www.cse.chalmers.se/edu/course/tmv026/ Accessible from Chalmers studieportalen. Check it regularly! Course Evaluation: I need 2 student representatives (1 GU + 1 CTH?) by Thursday this week. See web page of the course for last year s evaluation. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 3

Programming Bits in the Course The course doesn t require much programming tasks. Still we will present several algorithms to translate between different formalisations. I will sometimes show a Haskell program simulating certain automaton or implementing an algorithm. (Most of you should know Haskell, if not I really recommend you learn it: it is very elegant and nice!) You are welcome to test your knowledge implementing things in your favourite language! Lecture 1 March 21st 2011 TMV026/DIT321 Slide 4 Dictionary definition: Automata Main Entry: automaton Function: noun Inflected Form(s): plural automatons or automata Etymology: Latin, from Greek, neuter of automatos Date: 1645 1 : a mechanism that is relatively self-operating; especially : robot 2 : a machine or control mechanism designed to follow automatically a predetermined sequence of operations or respond to encoded instructions 3 : an individual who acts in a mechanical fashion Lecture 1 March 21st 2011 TMV026/DIT321 Slide 5

Automata: Applications Models for... Software for designing circuits Lexical analyser in a compiler Software for finding patterns in large bodies of text such as collection of web pages Software for verifying systems with a finite number of different states such as protocols Real machines like vending machines, telephones, street lights,... Application in linguistic, building of large dictionary, spell programs, search Application in genetics, regular pattern in the language of protein Lecture 1 March 21st 2011 TMV026/DIT321 Slide 6 Example: on/off-switch A simple non-trivial finite automaton: Push OFF ON Push States represented by circles. One state is the start state, indicated with an arrow into it. Arcs between states are labelled by observable events. Often we need one or more final states, indicated with a double circle. p Lecture 1 March 21st 2011 TMV026/DIT321 Slide 7

Functional Description of on/off-switch Let us define 2 functions f OFF and f ON representing the 2 states of the automaton. The input can be represented as a finite list give by N = 0 P N. The description of the automaton is: f OFF,f ON : N {Off,On} f OFF 0 = Off f OFF (P n) = f ON n f ON 0 = On f ON (P n) = f OFF n Lecture 1 March 21st 2011 TMV026/DIT321 Slide 8 Example: Simple Traffic Signal YR 1 0,1 0 GR RG 0 0,1 RY 1 Transitions: 0 (no traffic detected), 1 (traffic detected). The states represent a situation: GR one traffic light is Green and the other is Red. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 9

Example: Vending Machines A simple vending machine: p 5 kr choc q A more complex vending machine: 10 kr p 5 kr q 5 kr r choc big choc What does it happen if we ask for a chocolate on p? State q remembers it had got 5 kr already. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 10 Problem: The Man, the Wolf, the Goat and the Cabbage A man with a wolf, a goat and a cabbage is on the left bank of a river. There is a boat large enough to carry the man and only one of the other three things. The man wish to cross everything to the right bank. However if the man leaves the wolf and the goat unattended on either shore, the wolf surely will eat the goat. Similarly, if the goat and the cabbage are left unattended, the goat will eat the cabbage. Puzzle: Is it possible to cross the river without the goat or cabbage being eaten? Solution: We write all the possible transitions, and look for possible paths between two nodes. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 11

Solution: The Man, the Wolf, the Goat and the Cabbage M MWGC/ WC/ MWC/G M MW MC C/MWG MW MC W/C C/W MC MW MWG/C MC M /MWGC /WC G/MWC MW M Lecture 1 March 21st 2011 TMV026/DIT321 Slide 11 Overview of the Course Formal proofs Regular languages Context-free languages (Turing machines) Lecture 1 March 21st 2011 TMV026/DIT321 Slide 12

Formal Proofs Many times you will need to prove that your program is correct (satisfies a certain specification). In particular, you won t get a complex program right if you don t understand what is going on. Example: To make an iteration/recursion correct one needs an inductive hypothesis which is consistent with the iteration/recursion. Different kind of formal proofs: Deductive proofs Proofs by contradiction Proofs by counterexamples Proofs by (structural) induction Lecture 1 March 21st 2011 TMV026/DIT321 Slide 13 Example: Parity Counter The states of an automaton can be thought of as the memory of the machine. p 1 p 0 even odd p 1 p 0 Two events: p 0 and p 1. The machine does nothing on the event p 1. The machine counts the parity of the number of p 0 s. A finite-state automaton has finite memory! Lecture 1 March 21st 2011 TMV026/DIT321 Slide 14

Functional Description: Parity Counter Let us define 2 functions f even and f odd representing the 2 states of the automaton. The input can be represented by the data type T = 0 p 0 T p 1 T. The description of the automaton is: f even,f odd : T {Even,Odd} f even 0 = Even f even (p 0 n) = f odd n f even (p 1 n) = f even n f odd 0 = Odd f odd (p 0 n) = f even n f odd (p 1 n) = f odd n We now would like to prove that f even n = Even iff n contains an even number of constructors p 0. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 15 Example: on/off-switch Recall the description of the on/off-switch. We would like to prove that: the automaton is in state OFF after n pushes iff n is even and the automaton is in state ON after n pushes iff n is odd. Alternatively, we could prove that: f OFF n = Off iff n is even and f ON n = On iff n is odd. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 16

Regular Languages Finite automata were originally proposed in the 1940 s as models of neural networks. Turned out to have many other applications! In the 1950s, the mathematician Stephen Kleene described these models using mathematical notation (regular expressions, 1956). Ken Thompson used the notion of regular expressions introduced by Kleene in the UNIX system. (Observe that Kleene s regular expressions are not really the same as UNIX s regular expressions.) Both formalisms define the regular languages. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 17 Context-Free Languages We can give a bit more power to finite automata by adding a stack that contains data. In this way we extend finite automata into a push down automata. In the mid-1950s by Noam Chomsky developed the context-free grammars. Context-free grammars play a central role in description and design of programming languages and compilers. Both formalisms define the context-free languages. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 18

Church-Turing Thesis In the 1930 s there has been quite a lot of work about the nature of effectively computable (calculable) functions: Recursive functions by Stephen Kleene λ-calculus by Alonzo Church Turing machines by Alan Turing The three computational processes were shown to be equivalent by Church, Kleene, (John Barkley) Rosser (1934-6) and Alan Turing (1936-7). The Church-Turing thesis states that if an algorithm (a procedure that terminates) exists then, there is an equivalent Turing machine, a recursively-definable function, or a definable λ-function for that algorithm. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 19 Turing Machine (ca 1936 7) Simple theoretical device that manipulates symbols contained on a strip of tape. It is as powerful as the computers we know today (in term of what they can compute). It allows the study of decidability: what can or cannot be done by a computer (halting problem). Computability vs complexity theory: we should distinguish between what can or cannot be done by a computer, and the inherent difficulty of the problem (tractable (polynomial)/intractable (NP-hard) problems). Lecture 1 March 21st 2011 TMV026/DIT321 Slide 20

Learning Outcome of the Course After completion of this course, the student should be able to: Apply rigorously formal mathematical methods to prove properties of languages, grammars and automata; Understand the theory and principle of automata theory; Understand, differentiate and manipulate formal descriptions of languages, automata and grammars with focus on regular and context-free languages, finite automata and regular expressions; Use and define automata, regular expressions and context-free grammars to solve problems. Lecture 1 March 21st 2011 TMV026/DIT321 Slide 21