Formal languages and computation models

Similar documents
Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

A Characterization of the Chomsky Hierarchy by String Turing Machines

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems

Formal Grammars and Abstract Machines. Sahar Al Seesi

FAdo: Interactive Tools for Learning Formal Computational Models

ECS 120 Lesson 16 Turing Machines, Pt. 2

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

Theory of Programming Languages COMP360

Multiple Choice Questions

Turing Machine Languages

Lecture 4: Syntax Specification

Theory of Computation, Homework 3 Sample Solution

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

Theory of Computations Spring 2016 Practice Final Exam Solutions

Welcome to MTH401A!! Theory of Computation

A Note on the Succinctness of Descriptions of Deterministic Languages

Formal Languages and Compilers Lecture I: Introduction to Compilers

CSE 105 THEORY OF COMPUTATION

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Reflection in the Chomsky Hierarchy

CT32 COMPUTER NETWORKS DEC 2015

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

THEORY OF COMPUTATION

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

Slides for Faculty Oxford University Press All rights reserved.

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

This book is licensed under a Creative Commons Attribution 3.0 License


Formal Languages and Compilers Lecture IV: Regular Languages and Finite. Finite Automata

Languages and Compilers

CS402 - Theory of Automata Glossary By

Final Course Review. Reading: Chapters 1-9

Lexical Analysis. COMP 524, Spring 2014 Bryan Ward

The Front End. The purpose of the front end is to deal with the input language. Perform a membership test: code source language?

JNTUWORLD. Code No: R

1. [5 points each] True or False. If the question is currently open, write O or Open.

A Formalization of Transition P Systems

Theory of Computations Spring 2016 Practice Final

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

Equivalence of NTMs and TMs


CIT3130: Theory of Computation. Regular languages

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

Recursively Enumerable Languages, Turing Machines, and Decidability

UNIT I PART A PART B

KEY. A 1. The action of a grammar when a derivation can be found for a sentence. Y 2. program written in a High Level Language

COP 3402 Systems Software Syntax Analysis (Parser)

Problems, Languages, Machines, Computability, Complexity

Homework & Announcements

1 Parsing (25 pts, 5 each)

CS402 - Theory of Automata FAQs By

2.1 Sets 2.2 Set Operations

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Introduction to Lexical Analysis

Introduction to Lexical Analysis

Languages and Strings. Chapter 2

Recursive and Recursively Enumerable Languages

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

Lexical Analysis. Prof. James L. Frankel Harvard University

UNIT -2 LEXICAL ANALYSIS

Ling/CSE 472: Introduction to Computational Linguistics. 4/6/15: Morphology & FST 2

CSE 105 THEORY OF COMPUTATION

ECS 120 Lesson 7 Regular Expressions, Pt. 1

Lexical Analysis. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice.

Talen en Compilers. Jurriaan Hage , period 2. November 13, Department of Information and Computing Sciences Utrecht University

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

Decidable Problems. We examine the problems for which there is an algorithm.

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

Neha 1, Abhishek Sharma 2 1 M.Tech, 2 Assistant Professor. Department of Cse, Shri Balwant College of Engineering &Technology, Dcrust University

CSCI 340: Computational Models. Turing Machines. Department of Computer Science

Relational Database: The Relational Data Model; Operations on Database Relations

Finite-State Transducers in Language and Speech Processing

Outline. Language Hierarchy

Variants of Turing Machines

Lexical Analysis. Introduction

Lexical Analysis. Chapter 2

Regular Expressions & Automata

Formal Languages and Grammars. Chapter 2: Sections 2.1 and 2.2

CS 403: Scanning and Parsing

Theory and Compiling COMP360

CSE P 501 Compilers. Parsing & Context-Free Grammars Hal Perkins Winter /15/ Hal Perkins & UW CSE C-1

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata

Ambiguous Grammars and Compactification

Lecture 8: Context Free Grammars

Figure 2.1: Role of Lexical Analyzer

Lexical Analysis. Lecture 3-4

CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F

Limited Automata and Unary Languages

CSE 105 THEORY OF COMPUTATION

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Dr. D.M. Akbar Hussain

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.

Regular Languages. MACM 300 Formal Languages and Automata. Formal Languages: Recap. Regular Languages

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

DVA337 HT17 - LECTURE 4. Languages and regular expressions

Languages and Finite Automata

Transcription:

Formal languages and computation models Guy Perrier

Bibliography John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman - Introduction to Automata Theory, Languages, and Computation - Addison Wesley, 2006.

1 - General ideas 1. Introduction 2. Formal languages 3. Computation models 3

1.1 - Introduction The course aims at giving the theoretical foundations to understand the notions of programming language, interpretation and compilation of programming and data languages, complexity of a computation. The general framework is the theory of formal languages. Linguistics greatly contributed to its first developments (Chomsky 56) because of the proximity of formal languages with natural languages. Natural languages are essentially ambiguous and evolutionary, whereas formal languages are essentially non ambiguous and frozen.

1.1 - Introduction By analogy with linguistics, a computer program can be viewed as an utterance in a given language. As for an utterance in a natural language, a program must be parsed to be interpreted or to be translated into another language. Usually, the translation is performed to a lower level language; in this case, it is called compilation. Parsing is related to the syntax of the program whereas interpretation and compilation are related to its semantics.

1.1 - Introduction Parsing is performed by an abstract machine according to a computation model. This model depends on the concerned language. Generally, the complexity of parsing increases with the expressivity of the language. Parsing concerns not only programming languages but various kinds of formal languages (HTML, XML, Postscript, Tex, Latex ).

1.2 - Formal languages A formal language L over a finite alphabet Σ of symbols is a part of the set Σ* of words composed of symbols from Σ. The class of languages defined over Σ is equipped with the following operations : intersection, union, concatenation, Kleene closure, complementation. If L is infinite, it is important to have a computation procedure for recognizing L, that is for deciding if any word from Σ* belongs to L. If such a procedure exists, L is said to be recursive. If there exists only a computation procedure for enumerating L, L is said to be recursively enumerable.

1.3 - Computation models The foundation of the computation theory is due to Turing, who has formalized the concept of computation by designing general abstract machines (1936). A Turing Machine (TM) is composed of two parts: ü an infinite tape in one-to-one correspondence with Ζ and a pointer at the current position which can be read and written; ü A control unit which controls the forward and backward movements of the pointer as the actions of reading and writing on the tape.

1.3 - Computation models Formally, a TM is defined as a 5-uple (Q,, q 0, F, τ) such that : ü Q is the finite set of states of the unit control. ü is the finite tape alphabet of symbols plus a blank symbol which is not in. ü q 0 is a particular element of Q, the start state of the TM. ü F is a subset of Q, the accepting states of the TM. ü τ is a transition relation which associates a source state q 1 from Q, a tape input symbol a from { }, with an output symbol b from { }, a direction d of movement, which can takes the values L or R, and a target state q 2 from Q. This is denoted : τ (q 1, a, b, d, q 2 ).

1.3 - Computation models The principle of a Turing Machine : ü Initialisation: Initially, a word s from * is written on the tape. The other positions are filled with the blank symbol. A pointer indicates the position of the first symbol of s. (if s is empty, the initial position of the pointer does not matter). The control unit is initially in the state q 0. ü Transition step : a transition can occur if the control unit is in a state q 1, if the pointer indicates the symbol a on the tape, and if the TM has a transition (q 1, a, b, d, q 2 ) in its transition relation τ. In this case, the symbol a is replaced by b on the tape, the pointer moves to the next position on the left if d = L and on the right if d = R. Finally, the control unit moves to state q 2. ü Termination :If in a configuration of the TM, no transition is possible, the TM stops. At this moment, if the unit control is in accepting state, the input word is said to be accepted by the TM. The word on the tape at this moment constitutes the output word of the computation.

1.3 - Computation models The language recognized by a TM (Q,, q 0, F, d) is the set of words from,* that are recognized by this TM. A TM is deterministic (DTM) if its transition relation does not include two distinct transitions with the same source state and the same input symbol. A language is recursively enumerable if it is recognized by a TM. A language is recursive or decidable if there exists a TM that stops whatever input is and that recognizes this language. For a TM recognizing a recursive language, the function that associates any input of a DTM to the word read on the tape when the DMT stops in an accepting state is said to be a recursive (computable) function.

1.3 - Computation models : exercises 1. A TM is defined by the following transition table : τ 0 1 X Y s 0 (s 1, X, R) s 1 (s 1, 0, R) (s 2, Y, L) (s 1, Y, R) s 2 (s 4, 0, L) (s 3, X, R) (s 2, Y, L) s 3 (s 3, Y, R) (s 5, Y, R) s 4 (s 4, 0, L) (s 0, X, R) The initial state is s 0 and there is one accepting state s 5. a) What are the computations and possibly the output words produced by the MT with the following input words : 01 0101 0011 00011 b) What are the words built with 0 and 1 recognized by the MT?

1.3 - Computation models : exercises 2. Build a TM that recognizes the following languages : a) The set of even binary numbers. b) The set of sentences in French that contain the word la (we assume that there is no hyphens and no dots in such sentences except one full stop). c) The set of palindromes built with the letters a and b. d) The set of strings composed of an equal number of symbols a, b and c. e) The set of strings in the form w w such that w is any string composed of symbols a or b. 3. Build a TM that realizes the following recursive functions : a) A function that doubles any binary number. b) A function that removes all zeros on the right of any binary number. c) A function that removes all b from a string composed of symbols a or b and that removes the spaces between the remaining a. d) A function that reverses a string composed of symbols a or b