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

Slides:



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

CS 336 March 19, 2012 Tandy Warnow.
Lecture 24 MAS 714 Hartmut Klauck
Recursive Definitions and Structural Induction
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
CS21 Decidability and Tractability
Review of Mathematical Notation / Terminology
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
CS5371 Theory of Computation
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
CS 310 – Fall 2006 Pacific University Theoretical Computer Science CS 310 Chadd Williams Office Mon 10:30-11:30 am 202 Strain.
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.
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
Normal forms for Context-Free Grammars
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Theoretical Computer Science COMP 335 Fall 2004
1 CSCI 2400 section 3 Models of Computation Instructor: Costas Busch.
 2004 SDU Introduction to the Theory of Computation My name: 冯好娣 My office: 计算中心 430
Induction and recursion
Introduction Chapter 0. Three Central Areas 1.Automata 2.Computability 3.Complexity.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American.
INTRODUCTION TO THE THEORY OF COMPUTATION INTRODUCTION MICHAEL SIPSER, SECOND EDITION 1.
Chapter 4: Induction and Recursion
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
1 Chapter 1 Automata: the Methods & the Madness Angkor Wat, Cambodia.
Mathematical Preliminaries Strings and Languages Preliminaries 1.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Chapter 1 Introduction to the Theory of Computation.
CSCI 2670 Introduction to Theory of Computing Instructor: Shelby Funk.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
4.3 Recursive Definitions and Structural Induction Sometimes it is difficult to define an object explicitly. However, it may be easy to define this object.
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
CHAPTER 1 Regular Languages
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
THEORY OF COMPUTATION Komate AMPHAWAN 1. 2.
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.
Lecture 1 Overview Topics 1. Proof techniques: induction, contradiction Proof techniques June 1, 2015 CSCE 355 Foundations of Computation.
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.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
Classifications LanguageGrammarAutomaton Regular, right- linear Right-linear, left-linear DFA, NFA Context-free PDA Context- sensitive LBA Recursively.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 0 Introduction Some slides are in courtesy of Prof.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Models of Computation: Automata and Formal Languages Sam M. Kim.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar.
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
CSCE 355 Foundations of Computation
BCS2143 – Theory of Computer Science
Introduction to the Theory of Computation
CIS Automata and Formal Languages – Pei Wang
PROPERTIES OF REGULAR LANGUAGES
Computer Science Department
CSCE 355 Foundations of Computation
Jaya Krishna, M.Tech, Assistant Professor
Introduction to Automata Theory
INTRODUCTION TO THE THEORY OF COMPUTATION
Introduction to Finite Automata
CSCI-2400 Models of Computation.
Chapter 1 Introduction to the Theory of Computation
Presentation transcript:

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

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

Theory of Computation, Feodor F. Dragan, Kent State University 5 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 New York Paris Boston San Francisco Kent Stone Paper Scissors beats

Theory of Computation, Feodor F. Dragan, Kent State University 6 Strings and Languages Alphabet (any finite set of symbols) A string over an alphabet (a finite sequence of symbols from that alphabet) over is the length of string (=5) is an empty string the reverse of is substring, concatenation ( )

Theory of Computation, Feodor F. Dragan, Kent State University 7 Strings and Languages A language is a set of strings over a given alphabet ( ). Usual set operations as union and intersection can be applied to languages. is the length of (this is an infinite language) contains 001 as a substring is even  concatenation of two languages

Theory of Computation, Feodor F. Dragan, Kent State University 8 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 9 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 10 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

Theory of Computation, Feodor F. Dragan, Kent State University 11 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 12 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 13 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 14 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 15 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 16 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 title­ author 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 title­ author pairs being accumulated.