Quiz questions referenced here are on the Day 3 quiz

Slides:



Advertisements
Similar presentations
Recursive Definitions and Structural Induction
Advertisements

Recursively Defined Functions
The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Induction and Recursion. Odd Powers Are Odd Fact: If m is odd and n is odd, then nm is odd. Proposition: for an odd number m, m k is odd for all non-negative.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Lecture 4 Topics –Problem solving Subroutine Theme –REC language class The class of solvable problems Closure properties.
CSE115/ENGR160 Discrete Mathematics 03/31/11
Mathematical Induction
Induction and recursion
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Mathematical Maxims and Minims, 1988
Induction and recursion
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
Chapter 4: Induction and Recursion
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
1 CSSE 350 Automata, Formal Languages, and Computability.
MA/CSSE 474 Theory of Computation Functions, Closure, Decision Problems.
MA/CSSE 474 Theory of Computation Functions on Languages, Decision Problems (if time) Logic: Some harder parts.
MA/CSSE 474 Theory of Computation Enumerability Reduction.
MA/CSSE 474 Theory of Computation Decision Problems DFSMs.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
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)
Foundations of Discrete Mathematics Chapters 5 By Dr. Dalia M. Gil, Ph.D.
1 Recursive Definitions and Structural Induction CS 202 Epp section ??? Aaron Bloomfield.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
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.
Languages and Strings Chapter 2.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
The Big Picture Chapter 3.
The Big Picture Chapter 3. A decision problem is simply a problem for which the answer is yes or no (True or False). A decision procedure answers a decision.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
MA/CSSE 474 Theory of Computation Languages, prefixes, sets, cardinality, functions.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
Universal Turing Machine
MA/CSSE 474 Theory of Computation Decision Problems, Continued DFSMs.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
Chapters 11 and 12 Decision Problems and Undecidability.
MA/CSSE 474 Theory of Computation Functions on Languages, Decision Problems (if time) Logic: Some harder parts.
Chapter 4: Induction and Recursion
The Acceptance Problem for TMs
Advanced Algorithms Analysis and Design
MA/CSSE 474 Decision Problems Languages, Machines, Computation
Induction and recursion
Induction and Recursion
The Definition of Algorithm
Great Theoretical Ideas in Computer Science
CSE 105 theory of computation
HIERARCHY THEOREMS Hu Rui Prof. Takahashi laboratory
Mathematical Induction Recursion
Direct Proof and Counterexample V: Floor and Ceiling
How Hard Can It Be?.
Induction and recursion
NP-Complete Problems.
MA/CSSE 474 More Math Review Theory of Computation
CSE 105 theory of computation
Mathematical Induction
Induction: One Step At A Time
Instructor: Aaron Roth
CSE 105 theory of computation
Presentation transcript:

Quiz questions referenced here are on the Day 3 quiz MA/CSSE 474 Theory of Computation Decision Problems Quiz questions referenced here are on the Day 3 quiz

Total Orders A total order R  A  A is a partial order that has the additional property that: x, y  A ((x, y)  R  (y, x)  R). Example:  on the rational numbers If R is a total order defined on a set A, then the pair (A, R) is a totally ordered set. 6 5 4 3 Q7-8

Infinite Descending Chain A partially ordered set (S, <) has an infinite descending chain if there is an infinite set of elements x0, x1, x2, … S such that iℕ(xi+1< xi) Example: In the rational numbers with <, 1/2 > 1/3 > 1/4 > 1/5 > 1/6 > … is an infinite descending chain

Well-Founded and Well-Ordered Sets Given a partially ordered set (A, R), an infinite descending chain is a totally ordered, with respect to R, subset B of A that has no minimal element. If (A, R) contains no infinite descending chains then it is called a well-founded set. Used for halting proofs. If (A, R) is a well-founded set and R is a total order, then (A, R) is called a well-ordered set. Used in induction proofs. The positive integers are well-ordered The positive rational numbers are not well-ordered (with respect to normal <) Q9

Mathematical Induction Because the integers ≥ b are well-ordered: The principle of mathematical induction: If: P(b) is true for some integer base case b, and For all integers n ≥ b, P(n)  P(n+1) Then: For all integers n ≥ b, P(n) An induction proof has three parts: A clear statement of the assertion P. A proof that that P holds for some base case b, the smallest value with which we are concerned. A proof that, for all integers n ≥ b, if P(n) then it is also true that P(n+1). We’ll call the claim P(n) the induction hypothesis.

Sum of First n Positive Odd Integers The sum of the first n odd positive integers is n2. We first check for plausibility: (n = 1) 1 = 1 = 12. (n = 2) 1 + 3 = 4 = 22. (n = 3) 1 + 3 + 5 = 9 = 32. (n = 4) 1 + 3 + 5 + 7 = 16 = 42, and so forth. The claim appears to be true, so we should prove it.

Sum of First n Positive Odd Integers Let Oddi = 2(i – 1) + 1 denote the ith odd positive integer. Then we can rewrite the claim as: n  1 For reference; we will not do this in class The proof of the claim is by induction on n: Base case: take 1 as the base case. 1 = 12. Prove: = = n2+ Oddn+1. (Induction hypothesis.) = n2 + 2n + 1. (Oddn+1 = 2(n+1–1) + 1 = 2n + 1.) = (n + 1)2. Note that we start with one side of the equation we are trying to prove, and transform to get the other side. We do not treat it like solving an equation, where we transform both sides in the same way.

Strong induction To prove that predicate P(n) is true for all n≥b: Show that P(b) is true [and perhaps P(b+1) *] Show that for all j>b, if P(k) is true for all k with b≤ k<j, then P(j) is true. In symbols: j >b ((k (b≤k<j  P(k))  P(j)) * We may have to show it directly for more than one or two values, but there should always be a finite number of base cases. Notice

Fibonacci Running Time From Weiss, Data Structures and Problem Solving with Java, Section 7.3.4 Consider this function to recursively calculate Fibonacci numbers: F0=0 F1=1 Fn = Fn-1+Fn-2 if n≥2. def fib(n): if n <= 1: return n return fib(n-1) + fib(n-2) Let CN be the number of calls to fib during the computation of fib(N). It’s easy to see that C0=C1=1 , and if N ≥ 2, CN = CN-1 + CN-2 + 1. Prove that for N ≥ 3, CN = FN+2 + FN-1 -1. Point out that the initial formula for C is given by a recurrence relation Use induction. Base cases, N=3, N=4 Assume by induction that if N>=3, then CN and CN+1 are the right things. Show that CN+2 is the right thing. CN+2 = 1 + CN + CN+1 = (FN+2 + FN-1 – 1) + (FN+3 + FN – 1) + 1 = FN+4 + FN+1 – 1 = FN+2+2 + FN+2-1 – 1 Q10

Languages and Problems: The Big Picture Chapter 3

Decision Problems A decision problem is simply a problem for which the answer is yes or no (True or False). A decision procedure answers a decision problem. Examples: • Given an integer n, does n have a pair of consecutive integers as factors? • The language recognition problem: Given a language L and a string w, is w in L? Our focus in this course

The Power of Encoding Anything can be encoded as a string. For example, on a computer everything is encoded as a string of bits. <X> is the string encoding of X. <X, Y> is the string encoding of the pair X, Y. Problems that don’t look like decision problems about strings and languages can be recast into new problems that do look like that. What are some common ways of encoding integers: Decimal Binary Hex Unary

Web Pattern Matching Pattern matching on the web: • Problem: Given a search string w and a web document d, do they “match”? In other words, should a search engine, on input w, consider returning d? • The language to be decided: {<w, d> : d is a candidate match for the string w} Obviously we would need to define the criteria for candidacy more precisely in order to make this a reasonable language to study.

The Halting Problem Does a program always halt? • Problem: Given a program p, written in some some standard programming language L, is p guaranteed to halt, no matter what input it is given? • The language to be decided: HPALL = {pL : p halts on all inputs}

Primality Testing • Problem: Given a nonnegative integer n, is it prime? • An instance of the problem: Is 9 prime? • To encode the problem we need a way to encode each instance: We encode each nonnegative integer as a binary string. • The language to be decided: PRIMES = {w : w is the binary encoding of a prime integer}.

Graph Connectivity • Problem: Given an undirected graph G, is it connected? • Instance of the problem: 1 2 3 4 5 • Encoding of the problem: Let V be a set of binary numbers, one for each vertex in G. Then we construct G as follows: • Write |V| as a binary number, • Write a list of edges, Each pair of binary numbers represents one edge. • Separate all such binary numbers by “/”. 1/10/1/100/10/101/10/11 • The language to be decided: CONNECTED = {w  {0, 1, /}* : w = n1/n2/…ni, where each ni is a binary string and w encodes a connected graph, as described above}.

Protein Sequence Allignment • Problem: Given a protein fragment f and a complete protein molecule p, could f be a fragment from p? • Encoding of the problem: Represent each protein molecule or fragment as a sequence of amino acid residues. Assign a letter to each of the 20 possible amino acids. So a protein fragment might be represented as AGHTYWDNR. • The language to be decided: {<f, p> : f could be a fragment from p}.

Turning Problems into Decision Problems Casting multiplication as decision: • Problem: Given two nonnegative integers, compute their product. • Encoding of the problem: Transform computing into verification. • The language to be decided: L = {w of the form: <integer1>x<integer2>=<integer3>, where: <integern> is any well formed integer, and integer3 = integer1  integer2} 12x9=108  L 12=12  L 12x8=108  L First string is in the language; other two are not.

Turning Problems Into Decision Problems Casting sorting as decision: • Problem: Given a list of integers, sort it. • Encoding of the problem: Transform the sorting problem into one of examining a pair of lists. • The language to be decided: L = {w1 # w2: n1 (w1 is of the form <int1, int2, … intn>, w2 is of the form <int1, int2, … intn>, and w2 contains the same objects as w1 and w2 is sorted)} Examples: <1,5,3,9,6>#<1,3,5,6,9>  L <1,5,3,9,6>#<1,2,3,4,5,6,7>  L

Turning Problems Into Decision Problems Casting database querying as decision: • Problem: Given a database and a query, execute the query. • Encoding of the problem: Transform the query execution problem into evaluating a reply for correctness. • The language to be decided: L = {d # q # a: d is an encoding of a database, q is a string representing a query, and a is the correct result of applying q to d} Example: (name, age, phone), (John, 23, 567-1234) (Mary, 24, 234-9876)#(select name age=23)# (John)  L

The Traditional Problems and their Language Formulations are Equivalent By equivalent we mean that either problem can be reduced to the other. If we have a machine to solve one, we can use it to build a machine to do the other, using only the starting machine and other functions that can be built using machines of equal or lesser power. Reduction does not always preserve efficiency! .

An Example Consider the multiplication example: L = {w of the form: <integer1>x<integer2>=<integer3>, where: <integern> is any well formed integer, and integer3 = integer1  integer2} Given a multiplication machine, we can build the language recognition machine: Given the language recognition machine, we can build a multiplication machine: Given a machine that does integer multiplication how can we build a machine to recognize the multiplication language? Suppose we have a machine M(x,y) that multiplies two integers. Given a string in the form <int1>*<int2>=<int3> X = convertToInt(<int1>) Y = convertToInt(<int2>) Z = convertToInt(<int3>) If z = M(x,y) then accept. Else reject The other way around? Suppose we have a program P that checks whether strings like the one above are in INTEGERPROD. This program computes the product of two integers x and y. Enumerate the strings that are encodings of natural numbers. For each one, <z>, feed <x>*<y>=<z> to P. If P accepts, return z. Otherwise, keep going. P will eventually accept

Student Solution Presentations (as many as we have time for) Consider the English sentence, “If some bakery sells stale bread and some hotel sells flat soda, then the only thing everyone likes is tea.” This sentence has at least two meanings. Write two (logically different) first-order-logic sentences that correspond to meanings that could be assigned to this sentence. Use the following predicates: P(x) is True iff x is a person; B(x) is True iff x is a bakery; SB(x) is True iff x sells stale bread; H(x) is True iff x is a hotel; SS(x) is True iff x sells flat soda; L(x, y) is True iff x likes y; and T(x) is True iff x is tea. A.4 A.11(c) 2.5

Student Solution Presentations (as many as we have time for) A11(c) Using the definition of p (equivalence modulo p) that is given in Example A.4, let Rp be a binary relation on ℕ, defined as follows, for any p  1: Rp = {(a, b): a p b} So, for example, R3 contains (0, 0), (0, 3), (6, 9), (1, 4), etc., but does not contain (0, 1), (3, 4), etc. Is Rp a partial order? A total order? Prove your answer. A.4 A.11(c) 2.5

Student Solution Presentations (as many as we have time for) Consider the language L of all strings drawn from the alphabet {a, b} with at least two different substrings of length 2. Describe L by writing a sentence of the form L = {w  * : P(w)}, where  is a set of symbols and P is a first-order logic formula. You may use the function |s| to return the length of s. You may use all the standard relational symbols (e.g., =, , <, etc.), plus the predicate Substr(s, t), which is True iff s is a substring of t. A.4 A.11(c) 2.5

Student Solution Presentations (as many as we have time for) 2.8 For each of the following statements, state whether it is True or False. Prove your answer. (a) L1, L2 (L1 = L2 iff L1* = L2*). (c)Every infinite language is the complement of a finite language. (g) L1, L2 ((L1  L2)* = L1*  L2*). (l) L (  L+ = L*). A.4 A.11(c) 2.5