Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

Chapter Chapter Summary Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output Language Recognition Turing.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
1 CSCI-2400 Models of Computation. 2 Computation CPU memory.
1 Languages and Finite Automata or how to talk to machines...
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Theoretical Computer Science COMP 335 Fall 2004
CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state.
Topics Automata Theory Grammars and Languages Complexities
Finite State Machines Data Structures and Algorithms for Information Processing 1.
1 CSCI 2400 section 3 Models of Computation Instructor: Costas Busch.
Introduction Chapter 0. Three Central Areas 1.Automata 2.Computability 3.Complexity.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
CSC312 Automata Theory Lecture # 2 Languages.
CSC312 Automata Theory Lecture # 2 Languages.
Mathematical Preliminaries Strings and Languages Preliminaries 1.
Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.
1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,
1 Chapter 1 Introduction to the Theory of Computation.
Languages & Grammars. Grammars  A set of rules which govern the structure of a language Fritz Fritz The dog The dog ate ate left left.
Learning Automata and Grammars Peter Černo.  The problem of learning or inferring automata and grammars has been studied for decades and has connections.
CS 3813: Introduction to Formal Languages and Automata
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet:
Mathematical Notions and Terminology Lecture 2 Section 0.2 Fri, Aug 24, 2007.
Mathematical Preliminaries
THEORY OF COMPUTATION Komate AMPHAWAN 1. 2.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CS 3813: Introduction to Formal Languages and Automata
CS 203: Introduction to Formal Languages and Automata
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Three Basic Concepts Languages Grammars Automata.
Lecture 2 Overview Topics What I forgot from last lecture Proof techniques continued Alphabets, strings, languages Automata June 2, 2015 CSCE 355 Foundations.
1 Mathematical Preliminaries. 2 Sets Functions Relations Graphs Proof Techniques.
Mathematical Foundations of Computer Science Chapter 3: Regular Languages and Regular Grammars.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
BİL711 Natural Language Processing1 Regular Expressions & FSAs Any regular expression can be realized as a finite state automaton (FSA) There are two kinds.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Akram Salah ISSR Basic Concepts Languages Grammar Automata (Automaton)
Theory of Languages and Automata By: Mojtaba Khezrian.
Lecture #2 Advanced Theory of Computation. Languages & Grammar Before discussing languages & grammar let us deal with some related issues. Alphabet: is.
CONTEXT-FREE LANGUAGES
Formal Language & Automata Theory
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
BCS2143 – Theory of Computer Science
Introduction to the Theory of Computation
Languages.
CIS Automata and Formal Languages – Pei Wang
PROPERTIES OF REGULAR LANGUAGES
Natural Language Processing - Formal Language -
CSE 105 theory of computation
Theory of Computation Lecture # 9-10.
CSE 3813 Introduction to Formal Languages and Automata
Chapter 7 PUSHDOWN AUTOMATA.
Chapter 9 TURING MACHINES.
REGULAR LANGUAGES AND REGULAR GRAMMARS
CSCI-2400 Models of Computation.
Mathematical Preliminaries Strings and Languages
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Chapter 1 Introduction to the Theory of Computation
CSE 105 theory of computation
CSC312 Automata Theory Lecture # 2 Languages.
CSCE 355 Foundations of Computation
CSE 105 theory of computation
Presentation transcript:

Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION

Learning Objectives At the conclusion of the chapter, the student will be able to: Define the three basic concepts in the theory of computation: automaton, formal language, and grammar. Solve exercises using mathematical techniques and notation learned in previous courses. Evaluate expressions involving operations on strings. Evaluate expressions involving operations on languages. Generate strings from simple grammars. Construct grammars to generate simple languages. Describe the essential components of an automaton. Design grammars to describe simple programming constructs.

Theory of Computation Basic Concepts Automaton: a formal construct that accepts input, produces output, may have some temporary storage, and can make decisions Formal Language: a set of sentences formed from a set of symbols according to formal rules Grammar: a set of rules for generating the sentences in a formal language In addition, the theory of computation is concerned with questions of computability (the types of problems computers can solve in principle) and complexity (the types of problems that can solved in practice).

Review of Mathematical Preliminaries Sets: basic notation, operations (union, intersection, difference, and complementation), disjoint sets, power set, partitions. Functions and Relations: domain, range, total function, partial function, order of magnitude, equivalence relations. Graphs and Trees: vertices, edges, walk, path, simple path, cycle, loop, root vertex, parent, child, leaves, level, height. Proof Techniques: proof by induction and proof by contradiction.

Formal Languages Basic Concepts Alphabet: set of symbols, i.e. Σ = {a, b} String: finite sequence of symbols from Σ, such as v = aba and w = abaaa Empty string (λ) Substring, prefix, suffix Operations on strings: Concatenation: vw = abaabaaa Reverse: w R = aaaba Repetition: v 2 = abaaba and v 0 = λ Length of a string: |v| = 3 and |λ| = 0

Formal Languages Definitions Σ* = set of all strings formed by concatenating zero or more symbols in Σ Σ + = set of all non-empty strings formed by concatenating symbols in Σ In other words, Σ + = Σ* - { λ } A formal language is any subset of Σ* Examples: L 1 = { a n b n : n ≥ 0 } and L 2 = { ab, aa } A string in a language is also called a sentence of the language

Formal Languages Set Operations A language is a set. Therefore, set operations are defined as usual. If L 1 = { a n b n : n ≥ 0 } and L 2 = { ab, aa } Union: L 1 ᴜ L 2 = { aa, λ, ab, aabb, aaabbb, … } Intersection: L 1 ∩ L 2 = { ab } Difference: L 1 - L 2 = { λ, aabb, aaabbb, … } Complement: L 2 = Σ* - { ab, aa } Practice: Find L 2 – L 1

Formal Languages Other Operations New languages can be produced by reversing all strings in a language, concatenating strings from two languages, and concatenating strings from the same language. If L 1 = { a n b n : n ≥ 0 } and L 2 = { ab, aa } Reverse: L 2 R = { ba, aa } Concatenation: L 1 L 2 = { ab, aa, abab, abaa, aabbab, aabbaa, … } The concatenation L 2 L 2 or L 2 2 = { abab, abaa, aaab, aaaa } Star-Closure: L 2 * = L 2 0 ᴜ L 2 1 ᴜ L 2 2 ᴜ L 2 3 ᴜ … Positive Closure: L 2 + = L 2 1 ᴜ L 2 2 ᴜ L 2 3 ᴜ … Practice: Find (L 2 – L 1 ) R

Grammars Definition Precise mechanism to describe the strings in a language Def. 1.1: A grammar G consists of: V: a finite set of variable or non-terminal symbols T: a finite set of terminal symbols S: a variable called the start symbol P: a set of productions Example 1.11: V = { S } T = { a, b } P = { S  aSb, S  λ }

Grammars Derivation of Strings Beginning with the start symbol, strings are derived by repeatedly replacing variable symbols with the expression on the right-hand side of any applicable production Any applicable production can be used, in arbitrary order, until the string contains no variable symbols. Sample derivation using grammar in Example 1.11: S  aSb (applying first production)  aaSbb (applying first production)  aabb (applying second production)

The Language Generated by a Grammar Def. 1.2: For a given grammar G, the language generated by G, L(G), is the set of all strings derived from the start symbol To show a language L is generated by G: Show every string in L can be generated by G Show every string generated by L is in G A given language can normally be generated by different grammars

Equivalence of Grammars Two grammars are equivalent if they generate the same language For convenience, productions with the same left-hand sides are written on the same line Example 1.14: V = { A, S }, T = { a, b }, and productions S  aAb | λ A  aAb | λ The grammars in examples 1.11 and 1.14 can be shown to be equivalent

Automata An automaton is an abstract model of a digital computer An automaton consists of An input mechanism A control unit Possibly, a storage mechanism Possibly, an output mechanism Control unit can be in any number of internal states, as determined by a next-state or transition function.

Diagram of a General Automaton

Application Grammars for Programming Languages The syntax of constructs in a programming language is commonly described with grammars Assume that in a hypothetical programming language, Identifiers consist of digits and the letters a, b, or c Identifiers must begin with a letter Productions for a sample grammar:   | | λ  a | b | c  0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9