mc0082

8
MC0082 –Theory of Computer Science – 4 Credits Assignment Set – 1 Q1) Define the concept of equivalence relation. Give at least two examples of equivalence relation. Ans 1) Equivalence Relation Definition A relation is said to be an equivalence relation if it is reflexive, symmetric and transitive. If (a, b) is an element of the equivalence relation, then we write a ~ b and we say that a and b are equivalent. Let R be an equivalence relation on S and a is an element of S. Then the set [a] = {s S / s ~ a} is called the equivalence class of a (or equivalence class containing a). Example 1: If A = {a, b, c} and R = {(a, a), (b, b), (c, c), (a, b), (b, a)}, then R is an equivalence relation on A and [a] = {a, b}, [b] = {a, b}, and [c] = {c}. Example 2: i) Let S be the set of all integers. Define for any a, b S, a ~ b a - b is an even number. Then relation ~ is an equivalence relation. ii) Let R, the set of all real numbers, x ~ y x – y is an integer. Then ~ is an equivalence relation. The set of all equivalence classes are given by {[x] / x (0, 1]}.

description

MC0082 –Theory of Computer Science

Transcript of mc0082

Page 1: mc0082

MC0082 –Theory of Computer Science – 4 Credits

Assignment Set – 1

Q1) Define the concept of equivalence relation. Give at least two examples of equivalencerelation.

Ans 1) Equivalence Relation

Definition A relation is said to be an equivalence relation if it is reflexive, symmetric and transitive.

If (a, b) is an element of the equivalence relation, then we write a ~ b and we say that a and b are equivalent.

Let R be an equivalence relation on S and a is an element of S. Then the set [a] = {s S / s ~ a}

is called the equivalence class of a (or equivalence class containing a).

Example 1:

If A = {a, b, c} and R = {(a, a), (b, b), (c, c), (a, b), (b, a)}, then R is an equivalence relation on A

and [a] = {a, b}, [b] = {a, b}, and [c] = {c}.

Example 2:

i) Let S be the set of all integers. Define for any a, b S, a ~ b a - b is an even number. Then relation ~ is an equivalence relation.

ii) Let R, the set of all real numbers, x ~ y x – y is an integer. Then ~ is an equivalence relation. The set of all equivalence classes are given by {[x] / x (0, 1]}.

Q2) Prove by Mathematical Induction that

Ans 2)

i) For n=1, left side = 13 = 1

Page 2: mc0082

right side = = = 1

Hence it is true for n = 1

ii) Assume the result to be true for n = m

Then (induction hypothesis)

Adding the (m+1)th term viz.,(m+3)3 to both sides,

+ (m+1)3

= + (m2+4m+4)

=

=

Therefore the result is true for n = m+1.

Hence by mathematical induction the given result is established for all positive integers.

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

Ans 3)

Proof: Let G be a connected graph.

If G has no circuit, then G is a spanning tree.

If G has a circuit, then delete an edge from this circuit. If till leaves the graph connected.

Page 3: mc0082

If there are more circuits, repeat the operation till an edge from the last circuit is deleted, leaving the graph connected, circuitless, and contains all the vertices of G.

Thus the subgraph obtained is a spanning tree of G.

Hence every connected graph has at least one spanning tree.Q4) Prove that a b(modm) is an equivalence relation.

Ans 4)

To proof: The relation “a b mod m” is an equivalence relation on Z.

Solution: Let a Z.

Reflexive: Since n divides a - a = 0, we have a a mod m.

Symmetric: Let a b mod m. m divides a - b m divides - (a - b) m divides b - a b a mod m.

Transitivity: Let a, b, c Z such that a b mod m, b c mod m. m divides a - b, and m divides b - c m divides ( a - b ) + ( b - c) m divides a - c a c mod m.

Hence the relation is an equivalence relation.

Q5) Explain the concept of a Transition graph.

Ans 5)

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 a 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.

Page 4: mc0082

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.

Example

The graph represents the DFA,

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.

States 0 1 q0

q1

q0 q1

q1 q2

q2 q1q

2

Page 5: mc0082

Q6) Explain the steps of conversion of Mealy machine into Moore machine

Ans 6) Conversion of Mealy machine into Moore Machine

Consider the following steps: Step 1: For a state qi determine the number of different 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 a Moore machine. The common output of the new state table can be determined by examining the outputs under the next state columns of the original 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 output corresponding to the null string or we need to insert a new initial state at the beginning whose output is 0; the other row elements in this case would remain the same.

Consider the following example, to convert a given mealy machine into a Moore machine.

Present StateNext State

Input a = 0 Input a = 1State Output State Output

q1 q1 1 q2 0q2 q4 1 q4 1q3 q2 1 q3 1q4 q3 0 q1 1

After assessing the state table given above, we observe that the outputs for the states q1 and q4 are same while the outputs for the states q2 and q3, have two different values. Hence, after splitting states q2 and q3, we obtain the state table shown below.

Present StateNext State

Input a = 0 Input a = 1State Output State Output

q1 q1 1 q20 0

Page 6: mc0082

q20 q4 1 q4 1q21 q4 1 q4 1q30 q21 1 q31 1q31 q21 1 q31 1q4 q30 0 q1 1

Now, rearranging the state table as shown in table, into the Moore machine format, we obtain the state table as shown below.

Moore Machine

Present StateNext State

Input a = 0 Input a = 1 OutputState State

q1 q1 q20 1q20 q4 q4 0q21 q4 q4 1q30 q21 q31 0q31 q21 q31 1q4 q30 q1 1

Now, from the state table as shown above, we observe that the output corresponding to the initial state q1 is 1. Hence, to ensure that the Mealy and Moore machines are equivalent, we need to insert a row at the beginning of the state table with present initial state q0.

Moore Machine

Present StateNext State

Input a = 0 Input a = 1 OutputState State

q0 q1 q20 1q1 q1 q20 1q20 q4 q4 0q21 q4 q4 1q30 q21 q31 0q31 q21 q31 1q4 q30 q1 1