CSCI 1010 Theory of Computation HW1 Due: September 13, 2018 Attach a fully filled-in cover sheet to the front of your printed homework. Your name should not appear anywhere; the cover sheet and each individual page of the homework should include your Banner ID only. While collaboration is encouraged in this class, please remember not to take away notes from any labs or collaboration sessions. Please monitor Piazza, as we will post clarifications of questions there. Hand in your solutions by 10:20am to the CSCI 1010 bin on the second floor of the CIT. Late homeworks are not accepted. Problem 1 This problem uses the logical symbols representing AND, representing OR, and representing NOT. Conjunctive Normal Form (CNF) is a particular way of writing Boolean formulas that will be used in this course. We define it constructively: 1. A literal is a variable or its complement. x i and x i are examples of literals. 2. A clause is any disjunction (that is, OR) of any number of literals. A literal by itself is also a clause. 3. A formula is in conjunctive normal form if it is the conjunction (that is, AND) of any number of clauses. As an example, the formula (x 1 x 3 ) ( x 1 x 2 ) x 2 is in CNF. Using the above definition, convert the following formulas into equivalent formulas in conjunctive normal form. We say that two formulas are equivalent if they evaluate to the same truth value for each assignment of the variables (i.e., no matter how the variables are assigned true or false, the two formulas either both evaluate to true or both evaluate to false). a. (x 1 x 2 ) ( x 1 x 3 x 4 ) x 2
b. (x 1 (x 2 x 3 )) x 2 c. (x 1 x 2 ) x 3 d. (x 1 x 2 ) (x 2 x 3 ) (For parts (c) and (d), recall that denotes exclusive-or, where x 1 x 2 = (x 1 x 2 ) (x 1 x 2 ); denotes implies, where x 1 x 2 = x 1 x 2 ; and denotes if-and-only-if, where x 1 x 2 = (x 1 x 2 ) (x 2 x 1 ).) Problem 2 Oh no! The ClueFinders have wound up in trouble. The numbers 1 through n, which are attached to fire traps, will be arbitrarily arranged along a circle around them. In order to escape, the ClueFinders must find 4 numbers that appear consecutively along the circle that have a sum greater than or equal to 2n+2. Prove that, no matter how the numbers are arranged along the circle, the ClueFinders will be able to escape. Problem 3 You are playing a variant of the well-known game Snake, and start to notice a pattern in the snake s coloring. A snake contains squares arranged in a straight line (unlike regular Snake, the snake does not bend), and each square is colored either dark purple or light blue. In addition, the first square (the head) must be dark purple, and the last square must be light blue. The figure below shows an example of a snake. Prove that, in any snake, there are an odd number of places where consecutive squares are colored differently. For example, in the figure, there are three pairs of consecutive squares where one square is colored dark purple and the other is colored light blue. (Hint: it might help to think of the snake as a graph where the squares are vertices and consecutive squares are joined by an edge.) 2
The following questions are lab problems. Lab Problem 1 A CS1010 student hops onto their MySpace page and decides to do some graph analysis of their friend connections. They decide to represent people as vertices and friend connections as edges. So, MySpace is represented as a simple graph G = (V,E). First, some terminology: A simple graph is an undirected graph with no self-loops (an edge from a vertex to itself) or multiple edges (more than one edge between the same pair of vertices). A clique is a subset of vertices S V such that u,v S, (u,v) E (if u v). That is, every pair of vertices in S is connected by an edge in E. A vertex cover is a subset of vertices S V such that for any edge (u,v) E, u S or v S. Anindependent setisasubsetofverticess V suchthat u,v S, (u,v) / E. The complement of a simple graph G is the simple graph G = (V,E) on the same vertices such that, for every pair of (distinct) vertices u,v, we have (u,v) E if and only if (u,v) / E. Consider a graph G = (V,E). a. Show that a subset of vertices is an independent set in G if and only if it is a clique in G. b. Show that a subset of vertices S V is an independent set if and only if V \S is a vertex cover. Recall that \ denotes set difference, so V \S is the set of vertices not in S. Lab Problem 2 1. When it was first discovered that there are computational problems that cannot be solved by computers, it was a very surprising result. 3
In this problem, we will do a high-level argument of a related result. Gödel showed that there exist true mathematical statements that cannot be proven. Instead of using mathematical statements, we will simply use English sentences. This is the sentence we are trying to prove: There exists a true sentence for which there is no proof. We will argue this by contradiction. 1 That is, we will assume the following statement, then obtain a contradiction: Assumption: All true sentences have proofs. You may assume that any statement for which there exists a proof is true. (Hint: Examine the sentence S = No proof exists for this sentence. Show that given our assumption, if S is true or false, we obtain a contradiction.) 2. In class we looked at the Halting Problem, the problem of determining whether a program P will terminate on an input X. We wanted to know whether a program Jeeves (a mathematical butler) that solves the Halting Problem exists: Jeeves: Input: a program P, an input X Output: Yes if P terminates on X, No if P runs forever We concluded that Jeeves cannot exist, meaning that no program can solve the halting problem. We will now look at another problem that cannot be solved by computers: the problem of deciding the truth value of a sentence. We want to know whether a program TruthSolver exists: TruthSolver: Input: a sentence S Output: True if S is true, False if S is false 1 We are being informal here, because we have not given a mathematical formalization of the statement we are trying to prove. 4
Argue that TruthSolver cannot exist, by first showing that if we had a TruthSolver, we could use it to build a Jeeves. Then argue that since Jeeves cannot exist, TruthSolver cannot exist. (Hint: Jeeves will use TruthSolver as a subroutine. What kind of statement should it give as input?) Lab Problem 3 GLaDOS has just offered you a two-dimensional cake. While the cake is a lie, the claim that GLaDOS makes is true: if the cake is cut n times (each cut is a straight line), then each resulting slice of cake can be frosted with a different color than its adjacent slices (two slices are adjacent if they meet at an edge; they are not adjacent if they only touch at a corner). Here s the catch you only have two colors of frosting. Prove that you can frost the cake in this way, regardless of where the cuts are made. Here is an example of a valid frosting: 5