Theory of Computation

Similar documents
Topics COSC Administrivia. Topics Today. Administrivia (II) Acknowledgements. Slides presented May 9th and 16th,

Comment: The induction is always on some parameter, and the basis case is always an integer or set of integers.

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin

Chapter 6. Properties of Regular Languages

Mathematical Preliminaries. Sipser pages 1-28

Preliminaries to the Theory of Computation

Sri vidya college of engineering and technology

Introduction to Automata

Automata Theory and Formal Grammars: Lecture 1

Models of Computation. by Costas Busch, LSU

(Refer Slide Time: 0:21)

Automata Theory for Presburger Arithmetic Logic

What is this course about?

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Automata Theory, Computability and Complexity

Introduction to Languages and Computation

Finite Automata and Formal Languages

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

Theory of computation: initial remarks (Chapter 11)

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Context Free Language Properties

CHAPTER 1 Regular Languages. Contents

Computational Models: Class 3

CPSC 421: Tutorial #1

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2)

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

Theory of computation: initial remarks (Chapter 11)

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

Non-context-Free Languages. CS215, Lecture 5 c

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs

CISC4090: Theory of Computation

3515ICT: Theory of Computation. Regular languages

V Honors Theory of Computation

CSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission.

Cographs; chordal graphs and tree decompositions

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)

Lecture Notes on Inductive Definitions

Introduction to Theoretical Computer Science. Motivation. Automata = abstract computing devices

Properties of Context-Free Languages

3 The language of proof

Lecture Notes on Inductive Definitions

Proving languages to be nonregular

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

CSC236 Week 10. Larry Zhang

Foundations of Informatics: a Bridging Course

Computational Theory

Introduction to Languages and Computation

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Structural Induction

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

ECS 120 Lesson 15 Turing Machines, Pt. 1

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

CS243, Logic and Computation Nondeterministic finite automata

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Finite Automata and Formal Languages TMV026/DIT321 LP4 2012

Variants of Turing Machine (intro)

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Lecture 17: Language Recognition

Regular Expressions and Language Properties

Final Exam Comments. UVa - cs302: Theory of Computation Spring < Total

Decidability (intro.)

CS 173: Induction. Madhusudan Parthasarathy University of Illinois at Urbana-Champaign. February 7, 2016

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

Theory of Computation Lecture 1. Dr. Nahla Belal

Word-hyperbolic groups have real-time word problem

Further discussion of Turing machines

What we have done so far

Tree Adjoining Grammars

CS500 Homework #2 Solutions

The Pumping Lemma and Closure Properties

UNIT-VI PUSHDOWN AUTOMATA

CHAPTER 1. Relations. 1. Relations and Their Properties. Discussion

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Any Wizard of Oz fans? Discrete Math Basics. Outline. Sets. Set Operations. Sets. Dorothy: How does one get to the Emerald City?

1 Alphabets and Languages

Show Your Work! Point values are in square brackets. There are 35 points possible. Some facts about sets are on the last page.

Computational Models - Lecture 4

Computational Models - Lecture 4 1

Theory of Computation 1 Sets and Regular Expressions

1. Induction on Strings

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CPS 220 Theory of Computation

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

Theory of Computation

3130CIT Theory of Computation

The Pumping Lemma for Context Free Grammars

Graph Transformations T1 and T2

Grammars (part II) Prof. Dan A. Simovici UMB

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

CS481F01 Solutions 6 PDAS

INF210 Datamaskinteori (Models of Computation)

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

CS1800: Mathematical Induction. Professor Kevin Gold

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

CS375: Logic and Theory of Computing

Part I: Definitions and Properties

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

Transcription:

Theory of Computation (Feodor F. Dragan) Department of Computer Science Kent State University Spring, 2018 Theory of Computation, Feodor F. Dragan, Kent State University 1

Before we go into details, what are the two fundamental questions in theoretical Computer Science? 1. Can a given problem be solved by computation? 2. How efficiently can a given problem be solved by computation? Theory of Computation, Feodor F. Dragan, Kent State University 2

We focus on problems rather than on specific algorithms for solving problems. To answer both questions mathematically, we need to start by formalizing the notion of computer or machine. So, course outline breaks naturally into three parts: 1. Models of computation (Automata theory) Finite automata Push-down automata Turing machines 2. What can we compute? (Computability Theory) 3. How efficient can we compute? (Complexity Theory) Theory of Computation, Feodor F. Dragan, Kent State University 3

We start with overview of the first part Models of Computations or Finite State Automata Pushdown Automata Automata Theory First we will consider more restricted models of computation Then, (universal) Turing Machines We will define regular expressions and context-free grammars and will show their close relation to Finite State Automata and to Pushdown Automata. Used in compiler construction (lexical analysis) Used in linguistic and in programming languages (syntax) Theory of Computation, Feodor F. Dragan, Kent State University 4

Graphs G=(V,E) vertices (V), edges (E) labeled graph, undirected graph, directed graph subgraph path, cycle, simple path, simple cycle, directed path connected graph, strongly connected digraph tree, root, leaves degree, outdegree, indegree Stone New 599 Paris York Kent beats 109 378 Boston 378 San Francisco Paper beats beats Scissors Theory of Computation, Feodor F. Dragan, Kent State University 5

Strings and Languages Alphabet (any finite set of symbols) = {0,1} 1 = { a, b, c, 2 Γ = {0,1, x, y, z} d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z} A string over an alphabet (a finite sequence of symbols from that alphabet) w1 = 01001 over 1 w2 = abracadabra over 2 w1 is the length of string w 1 (=5) ε is an empty string the reverse of is w R 10010 w 1 = 1 k 678 xx Lx = x substring, concatenation ( k ) Theory of Computation, Feodor F. Dragan, Kent State University 6

Strings and Languages A language is a set of strings over a given alphabet ( 1 ). L = { w: w contains 001 as a substring } ε L 1 L 1 2 = { w: w 2 is the length of 1 (this is an infinite language) L L Usual set operations as union and intersection can be applied to languages. L = {11,001} L U L = {0,10,11,001} 1 1 2 L 2 = {0,10} is even concatenation of two languages L L 1 L L 2 2 1 Theory of Computation, Feodor F. Dragan, Kent State University 7 } L 1 I L 2 = {} = {110,1110,0010,00110} = {011,0001,1011,10001}

Definitions, theorems, proofs Definitions describe the objects and notations Defining some object we must make clear what constitutes that object and what does not. Mathematical statements about objects and notions a statement which expresses that some object has a certain property it may or may not be true, but must be precise A proof is a convincing logical argument that a statement is true A theorem is a mathematical statement proved true this word is reserved for statements of special interest statements that are interesting only because they assist in the proof of another, more significant statement, are called lemmas a theorem or its proof may allow us to conclude easily that another, related statements are true; these statements are called corollaries of the theorem Theory of Computation, Feodor F. Dragan, Kent State University 8

An example Definitions: A graph G=(V,E), a node v, an edge (v,u), # of edges E, incident, the degree d(v) of a node v, sum, even number. Theorem: For every graph G, the sum of the degrees of all the nodes in G is 2 E. Corollary: For every graph G, the sum of the degrees of all the nodes in G is an even number. OR Lemma: For every graph G, the sum of the degrees of all the nodes in G is 2 E. Theorem: For every graph G, the sum of the degrees of all the nodes in G is an even number. Proof: (easy) Theory of Computation, Feodor F. Dragan, Kent State University 9

Types of proofs: Proof by construction If theorem states that a particular type of object exists. A way to prove such a theorem is by demonstrating how to construct the object. A way to disprove a theorem is to construct an object that contradicts that statement (called a counterexample). Definition: A graph is k-regular if every node in the graph has degree k Theorem: For each even number n greater than 2, there exists a 3-regular graph with n nodes. Proof: Construct a graph G=(V,E) as follows. V = {0,1,..., n 1} E = {{ i, i U{{ i, i + 1}: for + n / 2}: 0 i for n 2} U{{ n 1,0}} 0 i n / 2 1} Theory of Computation, Feodor F. Dragan, Kent State University 10 9 10 8 11 7 6 0 5 1 4 2 3

Proof by induction Prove a statement S(X) about a family of objects X (e.g., integers, trees) in two parts: 1. Basis: Prove for one or several small values of X directly. 2. Inductive step: Assume S(Y ) for Y ``smaller than'' X; prove S(X) using that assumption. Theorem: A binary tree with n leaves has 2n-1 nodes. Proof: formally, S(T): if T is a binary tree with n leaves, then T has 2n - 1 nodes. induction is on the size = # of nodes in T. Basis: if T has 1 node, it has 1 leaf. 1=2 1, so OK Induction: Assume S(U) for trees with fewer nodes that T. T must be a root plus two subtrees U and V If U and V have u and v leaves, respectively, and T has t leaves, then u + v = t. By the induction hypothesis, U and V have 2u - 1 and 2v - 1 nodes, respectively. Then T has 1 + (2u 1) + (2v 1) nodes = 2 (u + v) 1 = 2 t 1, proving inductive step. Theory of Computation, Feodor F. Dragan, Kent State University 11

If-And-Only-If Proofs Often, a statement we need to prove is of the form X if and only if Y. We are often required to do two things: 1. Prove the if-part: Assume Y and prove X. 2. Prove the only-if-part: Assume X and prove Y. Remember: the if and only-if parts are converses of each other. one part, say if X then Y, says nothing about whether Y is true when X is false. an equivalent form to if X then Y is if not Y then not X : the latter is the contrapositive of the former. Equivalence of Sets many important facts in language theory are of the form that two sets of strings, described in two different ways, are really the same set. to prove sets S and T are the same, prove: x is in S if and only if x is in T. That is Assume x is in S; prove x is in T. Assume x is in T; prove x is in S. Theory of Computation, Feodor F. Dragan, Kent State University 12

Example: Balanced Parentheses Here are two ways that we can define ``balanced parentheses'': 1. Grammatically: a) The empty string ε is balanced. b) If w is balanced, then (w) is balanced. c) If w and x are balanced, then so is wx. 2. By Scanning : w is balanced if and only if: a) w has an equal number of left and right parentheses. b) Every prefix of w has at least as many left as right parentheses. Call these GB and SB properties, respectively. Theorem: A string of parentheses w is GB if and only if it is SB. Theory of Computation, Feodor F. Dragan, Kent State University 13

If part of the proof An induction on w (length of w). Assume w is SB; prove it is GB. Basis: If w = ε (length = 0), then w is GB by rule (a). Notice that we do not even have to address the question of whether is SB (it is, however). Induction: Suppose the statement ``SB implies GB'' is true for strings shorter than w. ε Case 1: w is not, but has no nonempty prefix that has an equal number of ( and ). Then w must begin with ( and end with ) ; i.e., w = (x). x must be SB (why?). By the IH, x is GB. By rule (b), (x) is GB; but (x) = w, so w is GB. Case 2: w = xy, where x is the shortest, nonempty prefix of w with an equal number of ( and ), and y is not. ε x and y are both SB (why?). By the IH, x and y are GB. w is GB by rule (c). ε Theory of Computation, Feodor F. Dragan, Kent State University 14

Only-If part of the proof An induction on w (length of w). Assume w is GB; prove it is SB. Basis: If w = ε (length = 0), then clearly w is SB. Induction: Suppose the statement ``GB implies SB'' is true for strings shorter than w, and assume that w is not. Case 1: w is GB because of rule (b); i.e., w = (x) and x is GB. by the IH, x is SB. Since x has equal numbers of ('s and )'s, so does (x). Since x has no prefix with more )'s than ('s, so does (x). ε ε Case 2: w is not and is GB because of rule (c); i.e., w = xy, and x and y are GB. By the IH, x and y are SB. (Aside) Trickier than it looks: we have to argue that neither x nor y could be, because if one were, the other would be w, and this rule application could not be the one that first shows w to be GB. xy has equal numbers of ('s and )'s because x and y both do. If w had a prefix with more )'s than ('s, that prefix would either be a prefix of x (contradicting the fact that x has no such prefix) or it would be x followed by a prefix of y (contradicting the fact that y also has no such prefix). (Aside) Above is an example of proof by contradiction. We assumed our conclusion about w was false and showed it would imply something that we know is false. Theory of Computation, Feodor F. Dragan, Kent State University 15 ε

Finite Automata An important way to describe certain simple, but highly useful languages called ``regular languages.'' A graph with a finite number of nodes, called states. Arcs are labeled with one or more symbols from some alphabet. One state is designated the start state or initial state. Some states are final states or accepting states. The language of the FA is the set of strings that label paths that go from the start state to some accepting state. Example This FA scans HTML documents, looking for a list of what could be titleauthor pairs, perhaps in a reading list for some literature course. It accepts whenever it finds the end of a list item. In an application, the strings that matched the title (before ' by ') and author (after) would be stored in a table of titleauthor pairs being accumulated. Theory of Computation, Feodor F. Dragan, Kent State University 16