Introduction to CS Theory Lecture 1 – Introduction Piotr Faliszewski [email protected].
-
Upload
arnold-heath -
Category
Documents
-
view
217 -
download
4
Transcript of Introduction to CS Theory Lecture 1 – Introduction Piotr Faliszewski [email protected].
Introduction to CS Theory
Lecture 1 – IntroductionPiotr [email protected]
Introduction
Instructor Piotr Faliszewski Office: 70-3575 Email: [email protected]
Course website: http://www.cs.rit.edu/~pf/theory/
Office hours Monday through Thursday 2pm—4pm
Logistics
Look at the courses website!
Important highlights Cooperation on homeworks
Teams of two allowed Both people get the same grade—you cannot
complain about your teammate not working Quizzes! Disputing your grade
At most a week after you received the grade
Discrete math quiz Next Monday
Introduction
This is a course in mathematics! Basic discrete math
Dealing with sets, functions, sequences etc. Logic Inductive proofs (!!!)
Goals of the course Understand the nature of computation Develop problem solving skills Increase mathematical sophistication
You should already be familiar with those, but we will review a bit as well
Computer Science Needs Precision!
From a letter of Charles Babbage to Alfred Tennyson in response to his poem "The Vision of Sin“:
"In your otherwise beautiful poem, one verse reads,
Every moment dies a man,Every moment one is born.
... If this were true, the population of the world would be at a standstill. In truth, the rate of birth is slightly in excess of that of death. I would suggest:
Every moment dies a man,Every moment 1 1/16 is born.
Strictly speaking, the actual figure is so long I cannot get it into a line, but I believe the figure 1 1/16 will be sufficiently accurate for poetry."
What is this course about?
Two fundamental questions about computation What can and cannot be
computed? What can and cannot be
computed efficiently?
But, before we can answer these… What IS computation? What PROBLEMS do
we want to solve?
What is computation? Many different models
of a computer Finite automata Push-down automata Turing machines
Decision problems and languages
Languages and Decision Problems
Decision problem Name Input
the mathematical entities about whose properties we ask
Question A well-defined yes/no
question
Language A set of strings Languages encode
decision problems
Example Name: Connectivity Input: Graph G, vertices
s and t Question: Are vertices s
and t connected in G
Languages and Decision Problems
Our two fundamental questions What decision problems
can and cannot be solved?
What decision problem can and cannot be solved efficiently
We focus on languages
Chomsky Hierarchy
Models of computation Regular languages /
finite automata Context-free
languages / push-down automata
Turing machines
Hierarchy of Languages
Finite languages
Context-freelanguages
Recursive languages
All languages
Effectively Decidable Languages
P
NP
Regularlanguages
Context-freelanguages
Recursive languages
And now…
Let’s get some real work done!
Your responsibility: Part I of the book But, I will cover:
Languages Mathematical induction
1.5 Languages
Language A set of strings over
some alphabet
Alphabet A finite set of indivisible
objects, usually denoted as Σ
Examples {0, 1, 2, …, 9} {0, 1} {a, b, c, …, z} {1}
String A string over Σ is a finite,
possibly empty, sequence of elements of Σ
Some strings over {0,1}: ε
empty string 0, 1, 001, 01010101
Examples of nonstrings (for alphabet {0,1}) 012011 11111…
Length of a string x |x| Examples?
Defining Languages
Set of all strings Σ* -- set of all strings
over Σ {0,1}*
{a}*
We can define languages via set operations Intersection, union Difference Complement operation
L = Σ* - L
Examples of languages
L1 = { x {0,1}* | x contains at least as many 0s as 1s}
L2 = { x {0,1}* | x contains at least as many 1s as 0s}
L3 = {ε}
L4 = { x {0,1}* | x viewed as an integer is a prime}
L5 = L1 L2
L6 = L1
Operations on Strings
Let x, y Σ*
Some operations on strings xy – concatenation
xi – concatenation of x i times with itself
x is a substring of y if there are strings w and z such that y=wxz
x is a prefix of y if there is a string z such that y=xz
x is a suffix of y if there is a string z such that y=zx
Examples x = ab y = aabb
xy = abaabb xε = x = εx
x3 = xxx = ababab x0 = ???
x is a substring of y z = bb z is a suffix of y x is a prefix of x
Operations on Languages
Let L, L1, L2 be languages over the same alphabet Σ
L1L2 = {xy | x in L1 and y in L2} – the concatenation of two languages
Li – concatenation of i L’s What is L0?
L* = L0 L1 L2 L3 … Kleene’s starL+ = LL* = L*L
Exercises Is there a language L such that L* is finite? Let L1, L2 be two finite languages. What is the cardinality of
L1L2
Is there a language such that L = L*?
Mathematical Induction
Mathematical induction Technique to prove facts
about finite entities E.g., properties of integers
Inductive proof: Base case Inductive step
Intuition … a little like a for loop in a
program: we construct the proof in iterations.
Theorem. Let A be a finite set with n elements. There are 2n distinct subsets of A.
Proof.Base: A = Inductive step:
Assume that the theorem holds for all natural numbers up to k.
Let A be a set with k+1 elements and B an arbitrary subset of k elements of A. Let x be such that:
A = B {x}
By the inductive assumption, B has 2k subsets. Thus A has 2k+1 subsets. (Why?)
Mathematical Induction – Examples
Let us prove the following:
Σ = {0,1}, each string x such that x = 0y1, where y Σ*, contains 01 as a substring
For every natural number n, n ≥ 2, n either is a prime or a product of two or more primes
How about the following theorem:
For every natural number n it holds that n! > 2n
And I can prove by induction that all horses are of the
same color!
Recursive Definitions
Recursive definition Define a small set of
basic entities Show how to obtain
larger ones from those already constructed
A bit like induction!
Examples
Factorial0! = 1For each natural n, (n+1)! = (n+1)*n!
Recursive definition of Σ*:1. ε Σ*
2. If x Σ* and a Σ then xa Σ*
3. Nothing is in Σ* unless it is obtained by the two previous rules.
Recursive Definitions – Examples
Two exercises Give a recursive
definition of the length of a string.
Give a recursive definition of a reverse of a string.
Palindromes A string is a palindrome if
it reads the same backward and forward
Let’s define a language of palindromes!
Language L of palindromes, Σ = {a, b}.1. ε L2. If x L then both axa and
bxb belong to L.3. Nothing belongs to L
unless it is obtained by rules 1 and 2.
Hmm… This looks wrong to
me!
Recursive Definitions – Examples
Language L of all strings with as many 0s as 1s. (Σ = {0,1})1. ε L2. For any x in L it holds
that each of: 0x1 1x0 01x 10x x01 x10belongs to L.
Is this definition correct?
Exercise
Prove that for each string x over alphabet Σ it holds that |x| = |xr|
xr is the reverse of x
Structural induction!