MC0082 –Theory of Computer Science

8
MC0082 –Theory of Computer Science 1. Define the concept of equivalence relation. Give at least two examples of equivalence relation. Definition: A relation R on a set A is an equivalence relation if and only if R is 1. Reflexive, 2. Symmetric, and 3. Transitive. The definition is motivated by observing that any process of “identification” must behave somewhat like the equality relation, and the equality relation satisfies the reflexive (x = x for all x), symmetric (x = y implies y = x), and transitive (x = y and y = z implies x = z) properties. Example. a) Let R be the relation on the set R real numbers defined by xRy i x − y is an integer. Prove that R is an equivalence relation on R. Proof. I. Reflexive: Suppose x ∈ R. Then x − x = 0, which is an integer. Thus, xRx. II. Symmetric: Suppose x, y ∈ R and xRy. Then x − y is an integer. Since y − x = −(x − y), y − x is also an integer. Thus, yRx.

description

SMU MCA MC0082 –Theory of Computer Science

Transcript of MC0082 –Theory of Computer Science

Page 1: MC0082 –Theory of Computer Science

MC0082 –Theory of Computer Science

1. Define the concept of equivalence relation. Give at least two examples of

equivalence relation.

Definition: A relation R on a set A is an equivalence relation if and only if R is

1. Reflexive,

2. Symmetric, and

3. Transitive.

The definition is motivated by observing that any process of “identification” must behave

somewhat like the equality relation, and the equality relation satisfies the reflexive (x = x

for all x), symmetric (x = y implies y = x), and transitive (x = y and y = z implies x = z)

properties.

Example.

a) Let R be the relation on the set R real numbers defined by xRy i x − y is an integer. ff

Prove that R is an equivalence relation on R.

Proof.

I. Reflexive: Suppose x R. Then x − x = 0, which is an integer. Thus, xRx.∈

II. Symmetric: Suppose x, y R and xRy. Then x − y is an integer. Since∈

y − x = −(x − y), y − x is also an integer. Thus, yRx.

III. Suppose x, y R, xRy and yRz. Then x − y and y − z are integers. Thus,∈

the sum (x − y) + (y − z) = x − z is also an integer, and so xRz.

Thus, R is an equivalence relation on R. #

b). Let R be the relation on the set of real numbers R in Example

1. Prove that if xRx ' and yRy' , then (x + y)R(x' + y').

Proof: Suppose xRx ' and yRy '. In order to show that (x+y)R(x'+y'), we must show that

(x + y) − (x ' + y') is an integer. Since

(x + y) − (x'+ y') = (x − x') + (y − y'),

and since each of x−x ' and y −y ' is an integer (by definition of R), (x−x') + (y −y ')

is an integer. Thus, (x + y)R(x ' + y').

Page 2: MC0082 –Theory of Computer Science

2. Prove by Mathematical Induction that

Base Step:

Let n=0 then the sum of the left side is 0.

Since there is nothing to add the expression on the right side is also 0

If n=1 then left side is 1

and

right side =

Hence the result is true for n=1

Induction Hypothesis:

Assume that the result to be true for n=m then

Adding the (m+1) th term i.e (m+1)3 to both side of the above equation

Page 3: MC0082 –Theory of Computer Science

3. Prove that a graph G is connected if and only if it has a spanning tree.

Suppose that a simple graph G has a spanning tree T. T contains every vertex of

G and there is a path in T between any two of its vertices. Because T is a sub graph of

G, there is a path in G between any two of its vertices. Hence, G is connected. Now

suppose that G is connected. If G is not a tree, it contains a simple circuit. Remove an

edge from one of the simple circuits. The resulting sub graph is still connected because

any vertices connected via a path containing the removed edge are still connected via a

path with the remaining part of the simple circuit. Continue in this fashion until there are

no more simple circuits. A tree is produced because the graph remains connected as

edges are removed. The resulting tree is a spanning tree because it contains every

vertex of G.

.

4. Prove that a≡ b(mod m) is an equivalence relation.

We simply use,

the definition of congruence modulo n: for any two integers a,b,

a≡b(modm)⟺a−b=km, for some k Z∈ .

The definitions of the three properties any equivalence relation must, by definition,

satisfy: reflexivity, symmetry, transitivity.

Reflexivity: for all a Z,∈ a∼a.

Is there a k Z∈ such that for integer a, a−a=mk?

Page 4: MC0082 –Theory of Computer Science

Symmetry: for all a,b Z,∈ if a∼b, then b∼a.

Is there a k2 Z∈ such that for integers a,b, if k1 is a integer such that a≡b(modm) so

that a−b=mk1 for some integer k1, then b-a=mk_2, and hence b \cong a \pmod m$?

Transitivity: for all a,b Z∈ , if a∼b, and b∼c, then a∼c

Can it be shown that:

a≡b(mod()m)⟶∃k1 Z, ∈ a−b=mk1

and

b≡c(modm)⟶∃k2 Z, ∈ b−c=mk2,

that there must exist some k3 Z∈ such that a−c=mk3?

5. Explain the concept of a Transition graph.

A finite directed labeled graph in which each node or vertex of the graph

represents a state and the directed edges from one node to another represent transition

of a state. All the edges of the transition graph are labeled as input/output. For example,

an edge labeled 1/0 specifies that for certain initial state if the input is 1, then the output

is 0.

Consider the following diagram:

In the transition graph as shown in the figure,

○ The initial state, q0, of the system is represented by a circle with an arrow

pointing towards it.

○ The final state, q1, is represented by two concentric circles.

○ The directed edges from the initial state to the final state are labeled as

input/output.

The graph represents the DFA,

Page 5: MC0082 –Theory of Computer Science

M = (Q= {q0, q1, q2}, Σ = {0,1}, δ, q0= initial state, F = {q1} ), where δ is given by,

δ(q0, 0 ) = q0,

δ(q0, 1 ) = q1,

δ(q1, 0 ) = q0,

δ(q1, 1 ) = q2,

δ(q0, 0 ) = q2,

δ(q2, 1 ) = q1

Representation of DFA using transition table,

In this method, the DFA is represented in the tabular form. This table is called

transitional table. There is one row for each state, and one column for each input. Since,

in the transition diagram shown in the fig., there are three states, there are three rows for

each state. The input symbols are only 0 and 1 so, there are two columns for the input

symbols. The transitional table for the diagram is given below.

6. Explain the steps of conversion of Mealy machine into Moore machine

Page 6: MC0082 –Theory of Computer Science

Consider the following steps

Step 1:

For a state qi determine the number of outputs that are available in θ state table of the Mealy

machine.

Step 2:

If the outputs corresponding to state qi in the next state columns are same, then retain state qi as

it is. Else, break qi into different states with the number of new states being equal to the number

of different outputs of qi.

Step 3:

Rearrange the states and outputs in the format of Moore machine.

The common output of the new state table can be determined by examining the outputs under the

next state columns of the Mealy machine.

Step 4:

If the output in the constructed state table corresponding to the initial state is 1, then this specifies

the acceptance of the null string ^ by Mealy machine. Hence, to make both the Mealy and Moore

machines equivalent, we either need to ignore the corresponding to null string or we need to

insert a new initial state at beginning whose output is 0; the other row elements in this case would

remain the same.