40 likes | 152 Views
Homework 1. Problem 1 & 2. Let A = { x {0,1}* | #0(x) = #1(x) } be the set of all bit strings that have as many ones as zeros. Some examples and counter examples of A are shown below: Ex: 10, 1010, 1001, 1110000,… Counter Ex: 0, 001, 100, 10011,…
E N D
Problem 1 & 2 Let A = { x {0,1}* | #0(x) = #1(x) } be the set of all bit strings that have as many ones as zeros. Some examples and counter examples of A are shown below: Ex: 10, 1010, 1001, 1110000,… Counter Ex: 0, 001, 100, 10011,… The language A can be defined inductively as follow: Basis case: e A. Closure case: if x , yA, then so are 1x0, 0x1, and xy. Problem 1 and 2 try to convince us that such definition is correct. 1. Define two functions #0, #1 : {0,1}* N to count the number of ones and zeros, respectively, occurring in an input bit string. ex: #1(1100) = 2; #0(1100) = #0(100111) = 2. You can suppose that the set of bit strings {0,1}* is defined as follows: Basis: : e {0,1}* Closure: if x {0,1}* then 0x and 1x {0,1}* . 2. Show the correctness of your definition of A by proving the followings: 2.1 for all x A, #0(x) = #1(x). – use structural induction 2.2. if x is a bit string which has as many ones as zeros, then x A.
Problem 3 & 4 3. Define recursively the set B = { x {0,1}* | #1(x) > #0(x) } of all bit strings that have more ones than zeros. (You may use the set A defined previously though it is not necessary. Hint: Analyze how a member of B can be formed as the concatenation of two members of B [and possibly some other bits.]) Ex: 1, 110, 101, 11110. Counter Ex: 0, 10, 001, 100, 0011,… 4. Show the correctness of your definition of B by proving the followings: 4.1 for all x in B, #1(x) > #0(x). – use structural induction 4.2. if x is a bit string which has more ones than zeros then x B.
Problem 5 • Show that the star operation * satisfies following equalities : For all language A • 5.1. A*A* = A* • 5.2. A** = A* • 5.3. A* = {e}U AA* • 5.4. AA* = A*A = A+. • Notes: • A* = {x1x2…xn | n 0 and all xi A } = {e} U A U A2 U A3 U … • A+ = {x1x2…xn | n > 0 and all xi A } = A U A2 U A3 U …