Download presentation
Presentation is loading. Please wait.
Published byArnold Heath Modified over 9 years ago
1
Introduction to CS Theory Lecture 1 – Introduction Piotr Faliszewski pf@cs.rit.edu
2
Introduction Instructor Piotr Faliszewski Office: 70-3575 Email: pf@cs.rit.edupf@cs.rit.edu Course website: http://www.cs.rit.edu/~pf/theory/ Office hours Monday through Thursday 2pm—4pm
3
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
4
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
5
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."
6
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
7
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
8
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
9
Hierarchy of Languages Finite languages Context-free languages Recursive languages All languages
10
Effectively Decidable Languages P NP Regular languages Context-free languages Recursive languages
11
And now… Let’s get some real work done! Your responsibility: Part I of the book But, I will cover: Languages Mathematical induction
12
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?
13
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 L 1 = { x {0,1} * | x contains at least as many 0s as 1s} L 2 = { x {0,1} * | x contains at least as many 1s as 0s} L 3 = {ε} L 4 = { x {0,1} * | x viewed as an integer is a prime} L 5 = L 1 L 2 L 6 = L 1
14
Operations on Strings Let x, y Σ * Some operations on strings xy – concatenation x i – 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 x 3 = xxx = ababab x 0 = ??? x is a substring of y z = bb z is a suffix of y x is a prefix of x
15
Operations on Languages Let L, L 1, L 2 be languages over the same alphabet Σ L 1 L 2 = {xy | x in L 1 and y in L 2 } – the concatenation of two languages L i – concatenation of i L’s What is L 0 ? L * = L 0 L 1 L 2 L 3 … Kleene’s star L + = LL * = L * L Exercises Is there a language L such that L * is finite? Let L 1, L 2 be two finite languages. What is the cardinality of L 1 L 2 Is there a language such that L = L * ?
16
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 2 n 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 2 k subsets. Thus A has 2 k+1 subsets. (Why?)
17
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! > 2 n And I can prove by induction that all horses are of the same color!
18
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 Factorial 0! = 1 For 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.
19
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.ε L 2.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!
20
Recursive Definitions – Examples Language L of all strings with as many 0s as 1s. (Σ = {0,1}) 1.ε L 2.For any x in L it holds that each of: 0x1 1x0 01x 10x x01 x10 belongs to L. Is this definition correct? Exercise Prove that for each string x over alphabet Σ it holds that |x| = |x r | x r is the reverse of x Structural induction!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.