![Page 1: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/1.jpg)
CSCI 4325 / 6339Theory of ComputationChapter One
Zhixiang Chen
Department of Computer Science
University of Texas-Pan American
![Page 2: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/2.jpg)
Background
Experience in at least one high-level programming language
Data structures Discrete math Others …
![Page 3: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/3.jpg)
Topics
What is computation? Or what is an algorithm?
Formal languagesand computing devices? Computation vs. Formal language understanding?
What can be computed? Or what cannot be computed?
What can be efficiently computed? Or what cannot be efficiently computed?
![Page 4: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/4.jpg)
Reading Materials
Chapter 0, Introduction
![Page 5: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/5.jpg)
The World of Theoretical Foundations of Computation
…
PARTIALLY COMPUTABLE
COMPUTABLE
PSPACE
NEXP
EXP
NP
P
![Page 6: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/6.jpg)
CHAPTER 0Introduction
![Page 7: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/7.jpg)
Automata, Computability, and Complexity Want to know
What are the fundamental capabilities and limitations of computers?
![Page 8: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/8.jpg)
Complexity
What makes some problem computationally hard and others easy?
How to classify problems according to their computational difficulties?
How to understand the computational difficulties in the worst case, randomized, or approximate settings?
How to harness the computational difficulties for applications like cryptography?
![Page 9: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/9.jpg)
Computability
What are limitations of Computers? Want to know what problems are solvable by
computers, and what are not? Note: In complexity, we are interested in
“solvable” problem, but want to know how difficult to solve.
![Page 10: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/10.jpg)
Automata
Automata theory deals with the definitions of properties of mathematical models of computation. These models play a role in several applied areas of computer science. Finite automata = regular expression: for text processing Context-free grammar: for programming language design and
implementation, AI, natural language processing Context-sensitive grammar: for natural language processing
![Page 11: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/11.jpg)
Sets
What is a Set? A set is a collection of objects
Ex’s? Notes:
We use capital letters to denote sets An object contained in a set is called a set element. We use lower-
case letters to denote set elements. Notations
Given a set A and an object x, if x is an element of A, we write
Otherwise we write
Ax
Ax
![Page 12: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/12.jpg)
Finite Sets and Infinite Sets
A set is finite if it has a finite number of elements Ex’s?
A set is infinite if it has an infinite number of elements Ex’s?
![Page 13: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/13.jpg)
Set Cardinality
Given a set A, the cardinality of A, denoted by |A|, is the number of elements
in A. Ex’s?
![Page 14: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/14.jpg)
Empty set
The empty set is a set without elements. The empty is denoted as Ø.
![Page 15: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/15.jpg)
Set Representation
By enumeration: List all elements. Only good for finite sets Ex’s.
A = {1, 2, 3, 4, 5}, B = {a, b, c, d, e} C = { Joe, Jose, Chen_1, Chen_ 2} D = { Black_Cat, White_Cat}
By Property: Give property for set elements. Good for infinite sets (and
finite sets as well) Ex’s.
A = {x: x is an integer} B = {y: y is a student at UTPA} C = {z: z is a student in the CS department} D = {w: and w is even}Aw
![Page 16: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/16.jpg)
Set Operations
Union A U B is a set of elements in either A or B A U B = {x: }
Intersection is a set of elements in both A and B.
Difference A – B is a set of elements in A but not in B.
BxAx
BA
}:{ BxAxxBA
}:{ BxAxxBA
![Page 17: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/17.jpg)
Set Operations
Subset if any implies
Proper Subset if and
Equivalence A = B if
Want example’s?
BxAxBA
BA BA BA
ABBA
![Page 18: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/18.jpg)
Properties of Set Operation Idempotency
A U A = A Commutativity
Associativity
ABBA
ABBA
)()(
)()(
CBACBA
CBACBA
![Page 19: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/19.jpg)
Properties of Set Operation Distributivity
Absorption
DeMorgan’s Law
)()()(
)()()(
CBCACBA
CBCACBA
AABA
AABA
)(
)(
)()()(
)()()(
CABACBA
CABACBA
![Page 20: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/20.jpg)
Can You See DeMorgan’s Law?
A
B
C
)()()(
)()()(
CABACBA
CABACBA
![Page 21: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/21.jpg)
Disjoint Sets and Power Sets Disjoint Sets
A and B are disjoint if Power Sets
Given a set A, the power set of A, denoted by is the collection of all subsets of A.
Ex’s.
A = {1, 2, 3} = {, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
.BA
A2
}.:{2 AXXA
A2
![Page 22: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/22.jpg)
Two Notations
Let S be a set such that any element in S is also a set, define
Ex’s
What is ? What is ?
},:{
},:{
PxSPxPS
PxSPxPS
SP
SP
A
A
2
2
![Page 23: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/23.jpg)
Set Partition
Given a nonempty set A, we say is a partition of A if Any two elements of are disjoint.
AXX
A
}{2
![Page 24: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/24.jpg)
Set Partition Examples
Ex’s Let S = {a, b, c, d} What partition of S has the fewest members? The
most members? List all partitions of S with exactly two members?
![Page 25: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/25.jpg)
Relations and Functions- Ordered Pairs Given any two objects a, b, let (a, b) denote the
ordered pair of a and b. The ordered pair of a and b tells that a and b is
related under some relationship The differences between (a, b) and {a, b}:
(a, b) (b, a), while {a, b} = {b, a} (a, a) is a good ordered pair, while {a, a} is not.
The equivalence (a, b) = (c, d) if and only if a = c, b = d.
![Page 26: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/26.jpg)
Ordered Tuples
Given any n objects is an n-ary ordered tuple.
Note: The objects may not be distinct.
Ordered tuple examples?
,,,, 21 naaa ),,,( 21 naaa
,,,, 21 naaa
![Page 27: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/27.jpg)
Cartesian Products
Given two sets A and B, the Cartesian Product of A and B is
Given n sets , the n-fold Cartesian Product of these sets is
Ex’s?
}:),{( BbAabaBA
}1,:),,,{( 2121 niAaaaaAAA iinn
nAAA ,,, 21
![Page 28: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/28.jpg)
Relations
A binary relation is defined as
A n-ary relation is defined as
BAR :BAR
BAAAR n 21:
BAAAR n 21
![Page 29: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/29.jpg)
Functions
A function is a binary relation on A and B such that there is exactly one such that A is called the domain of f.
For any , we denote y as f(x). f(x) is called the image (or value) of x.
The range of f is defined as f [A] = { y: y = f(x) for some }
BAf :
,Ax By .),( fyx
Ax
fyx ),(
![Page 30: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/30.jpg)
Function Mapping
A Bf
![Page 31: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/31.jpg)
One-to-One, Onto, Bijection
One-to-One A function is one-to-one if for any two distinct
elements Onto
A function is onto B, if
Bijection A function is a bijection if f is one-to-one and
onto
BAf :
).()(,, bfafAba
BAf :
).(,, xfyAxBy
BAf :
![Page 32: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/32.jpg)
Inverse
The inverse of a binary relation is
The inverse of a function may not be a function any more. Why?
If a function is bijection then its inverse is still a function. Why?
BAR :}),(:),{(1 RbaabR
![Page 33: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/33.jpg)
Composition
Let Q and R to be two relations
Then RQ is also a relation
,: BAQ CBR :
CARQ :
}),(),(,:),{( RzyQyxByzxRQ
A B C
Q R
![Page 34: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/34.jpg)
Composition Examples
Let R = {(a, b), (a, c), (c, d), (a, a), (b, a)}, What is RR? What is ? Is R, RR or a function?
1R1R
![Page 35: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/35.jpg)
Graph Representation of a Binary Relation Given a binary relation
for each draw a node to represent a, draw another node to represent b, draw an edge from a to b. Then, we obtain a directed graph for R.
,: AAR
,),( Rba
![Page 36: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/36.jpg)
An Graph Representation Example Let R = {(a, b), (b, a), (a, d), (d, c), (c, c),
(c, a)}. The Graph is
a b
cd
![Page 37: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/37.jpg)
Reflexive
A relation R: A→A is reflexive, if for any
For a reflexive relation R, the directed graph for R has a self-circle for each node
Graph example? Other examples?
The less-than-or-equal-to relation over integers
.),(, RaaAa
![Page 38: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/38.jpg)
Symmetric
A relation R: A→A is symmetric if for any
In the directed graph of a symmetric relation, if there is an edge from node a to node b, then there must be another edge from node b to node a.
Graph examples? Other Examples?
The friend relation over a group of people.
.),(,),( RabRba
![Page 39: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/39.jpg)
Antisymmetric
A relation R: A A is antisymmetric if for any
In the direct graph of a antisymmetric relation, if there is an edge from a to b, then there must be no edge from b to a.
Some graph examples? Other examples?
The parent relation over a group of people.
.),(,),( RabRba
![Page 40: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/40.jpg)
Transitive
A relation R:A A is transitive if (a, b) and(a, c) are in R, then (a, c) is also in R.
In the directed graph of a transitive relation, if there a path from a to b, then there is an edge from a to b.
Some graph examples? Other examples?
The ancestor relation over a group of people. The less-than relation over integers.
![Page 41: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/41.jpg)
Equivalence Relation
A relation R: A A is equivalent if R is reflexive, symmetric and transitive.
Let R be an equivalence relation, for any a in A, we define the equivalence class containing the element a as [a] = {x: (a, x) in R} That is, [a] is the set of all elements related to a.
Examples? The same-family relation The x=y (mod p) relation for the given p.
![Page 42: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/42.jpg)
A Equivalence Relation Theorem Theorem. Let R: A→A to be an equivalence
relation, then the equivalence classes of R is a partition of A. That is {[a]: a in A} is a partition of A.
Proof.
AaAa
][
],[2,1 aSSAa
.2121 SSorSSeither
![Page 43: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/43.jpg)
Partial Order A relation R: A→A is a partial order if R is
reflexive, antisymmetric, and transitive. Ex’s
Some graph examples? The boss-employee relation, assuming any
person is the boss of him/herself. Minimal elements of a partial order R: A→A
An element a in A is minimal if for any b in A, (b, a) in R implies b = a.
Ex’s
![Page 44: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/44.jpg)
Total Order, Path, Length, Cycles Total Order
A relation R: A A is a total order, if R is a partial order, and for any a, b in A, either (a, b) in R or
(b, a) in R. Path, Length, Cycles
Easy to see from the directed graph of a relation R.
Examples?
![Page 45: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/45.jpg)
Countable and Uncountable Sets Countable
A set S is countable if one of the following is true S is finite S is infinite but there is a bijection f: SN, where N is
the set of natural numbers. In other words, S is countable, if elements in S are
enumerable. Countable set examples? Uncountable
Sets that are not countable
![Page 46: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/46.jpg)
Unions of Countable Sets
The union of a finite collection of countable sets is countable Proof. By dovetailing
The Union of a countably infinite collection of countable sets is countable Proof. By dovetailing
![Page 47: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/47.jpg)
There Are Uncountable Sets
Proof. By diagonalization. Will give a proof later.
![Page 48: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/48.jpg)
Definitions
Definitions describe the objects and notions that we use. A definition may be simple, or complex. Precision is essential to any mathematical definition. When defining some object we must make clear what constitutes that object and what does not.
![Page 49: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/49.jpg)
Theorems
A theorem is a mathematical statement proved true. Generally a theorem is used to refer to a mathematical statement of special interest. Sometimes we prove statements that are interesting only because they assist in the proof of another, more significant statement. Such statements are called lemmas. Occasionally a theorem or its proof may allow us to conclude easily that other, related statements are true. These statements are called corollaries of the theorem.
![Page 50: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/50.jpg)
Proofs
A proof is a convincing logical argument that a statement is true. In mathematics an argument must be airtight, that is, convincing in an absolute sense. This is rather different from the notion of proof that we use in everyday life or in the law. A mathematician demands proof beyond any doubt.
![Page 51: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/51.jpg)
Five Fundamental Proof Techniques Proof by Mathematical Induction Proof by Construction Proof by Contradiction Proof by Pigeon Hole Principle Proof by Diagonalization
![Page 52: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/52.jpg)
Mathematical Induction
The Principle of Math Induction: Let A be a set of natural numbers such that
and For each natural number , if then ,
then, A = N
Math Induction can be used to prove the following assertion For all natural numbers n, property P(n) is true.
A00n An 1An
![Page 53: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/53.jpg)
Three Steps of Math Induction To show property P(n) is true for all natural
numbers, follow the following three steps: Base case: show P(0) is true. Induction hypothesis: Assume P(n) is true Induction: show P(n+1) is true.
![Page 54: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/54.jpg)
Math Induction Example
Show that for any
Proof. (Prove in class.)
,0n
2
)1(21
nnn
![Page 55: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/55.jpg)
Proof by Construction
Many theorems state that a particular type of object exists. One way to prove such a theorem is by demonstrating how to construct the object.
Theorem. For any even number n greater than 2, there exists a graph with n nodes such that every node has exactly 3 edges connecting to it.
Proof. By Construction.
![Page 56: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/56.jpg)
Proof by Contradiction
We assume that the theorem is false and then show that this assumption leads to an obviously false consequence, called a contradiction.
Theorem. is irrational. Proof. By contradiction. (do it in class.)
2
![Page 57: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/57.jpg)
The Pigeonhole Principle
The Principle. Let m pigeons to sit in n holes, if m > n then there is at least one hole with at least 2 pigeons.
Ex: Let R to be a binary relation on a finite set A, and let a, b be in A. If there is a path from a to b in R, then there is a path of length at most |A|.
Proof . By Pigeonhole Principle.
![Page 58: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/58.jpg)
Diagonalization
The Principle. Let R to be a binary relation on a set A, define D = {a: a in A and (a, a) not in R}
For any a in A, define = {b: b in A and (a, b) in R}
Then, for any a in A,
aD
aDD
![Page 59: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/59.jpg)
Applications of Diagonalizations
Theorem 1. Let [0, 1] denote the set of all real numbers between 0 and 1. Then it is uncountable.
Proof. By diagonalization. (Do it in class.)
Theorem 2. is uncountable, where N is the set of all nature numbers.
Proof. By diagonalization. (Do it in class.)
N2
![Page 60: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/60.jpg)
Closures and Algorithms
The idea of reflexive transitive closure of a relation R is to find a smallest reflexive and transitive relation to cover R.
Ex.
R:
a1 O O a4
a2 O O a3
R*: a1 a4
a2 a3
R* is reflexive and transitive closure of R.
![Page 61: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/61.jpg)
Reflexive Transitive Closure
Definition: Let R: A X A be a relation. The transitive closure of R is the relation R* = {(a, b): a, b are in A and there is a path from
a to b in R or a = b} Give R, how to find the transitive closure R*
of R? Suppose A = {a1, a2, . . . , an}
![Page 62: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/62.jpg)
Closure Algorithm 1
Algorithm 1 Initially R* = For i = 1, . . . , n do For each i-tuple (b1, . . ., bi) in do
if (b1, . . ., bi) is a path in R then add (b1, bi) to R
iA
![Page 63: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/63.jpg)
Closure Algorithm 2
Algorithm 2 Initially R* = R {(ai, ai) : ai in A} For j = 1, 2, . . ., n do
For i = 1, 2, . . ., n and k = 1, 2, . . ., n do If (ai, aj), (aj, ak) are in R* but (ai, ak) are not in R* then
add (ai, ak) to R*
![Page 64: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/64.jpg)
Algorithm Analysis
How to show the correctness of the two closure algorithms? Do they halt on any given input? If halt, Do they output the right result? What are the performances of the two algorithms
Time complexity Space complexity
How to analyze the performance?
![Page 65: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/65.jpg)
Big-O Notation
Let f, g be two functions from N to N. f(n) = O(g(n)) if there are two constants c and such that for all
Ex. But
More Ex’s ?
0nn)()( ncgnf
0n
)(16100 525 nOnn )(16100 225 nOnn
![Page 66: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/66.jpg)
Time Complexity of the Two Closure Algorithms
Algorithm 1
Algorithm 2
Which algorithm is better?
)( 1nnO
)( 3nO
![Page 67: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/67.jpg)
Alphabets and Languages
Consider Pascal Consider English Observation:
Language = Alphabet + Syntax + Semantics Alphabet
A finite set of symbols Ex’s?
{0, 1}, {a, . . . , z, A, . . . , Z}
![Page 68: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/68.jpg)
Strings
A string of an alphabet A sequence of symbols from the alphabet.
Ex’s 1010 of {0, 1} ILovetheory of {a, . . . , z, A, . . . , Z}
Empty string a string without symbols denoted by e.
![Page 69: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/69.jpg)
String Length
The length of a string w the number of occurrences of symbols in w,
denoted by |w| Ex’s
|1010|= 4 |ILoveTheory|= 11 |e|=0
![Page 70: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/70.jpg)
String Concatenation
Concatenation of two strings x, y: xy is the string of x followed by y. |xy|=|x| +|y|
![Page 71: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/71.jpg)
Substring, Prefix, Suffix
z is a substring of w if there are strings x, y such that w = xyz Ex. Find substrings of “Iiovetheory”
z is a prefix of w if there is a string x such that w = zx Ex. Find prefixes of “Iiovetheory”
z is a suffix of w if there is a string x such that w = xz Ex. Find suffixes of “Iiovetheory”
![Page 72: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/72.jpg)
Power of a String
The power of a string w Given any natural number i,
.0
,0,1 iifww
iifew ii
![Page 73: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/73.jpg)
Reversal of a String
The reversal of a string w
where a is some letter in the alphabet
Property
,
,0||,
auwifau
wifew RR
RRR xyxy )(
![Page 74: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/74.jpg)
Σ, Σ*, and Languages
Let Σ be any finite alphabet {a1, a2, . . . , an} Σ* denote the set of all strings of Σ Any subset L of Σ* is called a language over Σ. Ex’s: Pascal, English, binary numbers, decimal
numbers, etc.
Note: Languages are defined as sets. Thus, all set operations such as union, intersection, difference, complement are all applicable to languages.
![Page 75: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/75.jpg)
Concatenation and Kleene Star Concatenation of Languages: Given two
languages and , the concatenation
of and is
Kleene Star: the Kleene star of a language L is
Ex’s = {a, b}, = {11}
},,,,0:{ 2121* LwwwkwwwL kk
}:{ 22112121 LwLwwwLL
2L1L
1L
1L
2L
2L
![Page 76: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/76.jpg)
The closure of a language
The closure of a language L:
Ex. Find the closures of the following languages L1 = {a, b}, L2 = {11}
},,,,1:{ 2121* LwwwkwwwLLL kk
![Page 77: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/77.jpg)
Finite Representations of Languages The Large Picture
Given an alphabet Σ, the collection of all languages over Σ is
when , Σ* is countably infinite,
is uncountably infinite.
1||
*
2
*
2
![Page 78: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/78.jpg)
Finite Representation of a Language A finite representation of a language
is a finite string of some other finite alphabet .
The total number of languages represented by strings of is .
is countably infinite.
Can you get some conclusion?
*
2L
|| *
*
![Page 79: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/79.jpg)
The Language World
All languages
Finitely representable languages
![Page 80: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/80.jpg)
Regular Expressions
Definition. Regular expressions over a given alphabet Σ are defined as follows: (1) Φ and any symbol of Σ are regular exp. (2) If α and β are regular expressions, then so are
(α β), (α U β ), and α* (3) Only those derived from (1) and (2) are regular
expressions Ex’s. Σ = {a, b}
Φ, a, b, (ab), (aa)*, (aabb)*, (aba)*(bb)*
![Page 81: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/81.jpg)
Regular Languages
Languages defined by regular expressions Given a regular expression α, let L(α) denote the
language represented by α. We have L(Φ) = Φ, L(a) = {a} for a Σ L(α U β ) = L(α) U L(β) L(αβ) = L(α) L(β) L(α*) = L(α)*
Ex’s (give examples in class.) A language L is regular if there is a regular
expression α such that L = L(α).
![Page 82: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/82.jpg)
Non-Regular Languages
There are languages which are not regular
Ex’s
}:{
}0:{*
wwwB
nbaAR
nn
![Page 83: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/83.jpg)
Recognizable & Generatable
A and B are recognizable Ex.
We can write a C++ program which, given any string w Σ*, can decide whether w in A or not
A and B are generatable Ex. We can write a C++ program to enumerate all
elements of A, provided we have infinite supply of paper and computing time and space.
![Page 84: CSCI 4325 / 6339 Theory of Computation Chapter One Zhixiang Chen Department of Computer Science University of Texas-Pan American](https://reader036.vdocument.in/reader036/viewer/2022062408/56649e9e5503460f94ba0465/html5/thumbnails/84.jpg)
A New World of Languages
All languages
Finitely representable languages
Regular languages