0% found this document useful (0 votes)
21 views5 pages

pdf

Uploaded by

meenajyoti7678
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views5 pages

pdf

Uploaded by

meenajyoti7678
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Question 1

In[120]:=
A1 = {{1, 1}, {1, 2}, {2, 2}, {3, 4}, {4, 4}}
Out[120]=
{{1, 1}, {1, 2}, {2, 2}, {3, 4}, {4, 4}}

In[121]:=
FindDomain[R _] := Union[Flatten[R, 1]]

In[122]:=
FindDomain[A1]
Out[122]=
{1, 2, 3, 4}

In[123]:=
reflexiveQ2[R _] := Module{D}, D = FindDomain[R];
Fori = 1, i ≤ Length[D], i ++,
If! MemberQR, Di, Di, Return[False];
Return[True]
In[124]:=
reflexiveQ2[A1]
Out[124]=
False

In[125]:=
Needs["Combinatorica`"]

In[126]:=
SymmetricQ[FromOrderedPairs[A1]]
Out[126]=
False

In[127]:=
AntiSymmetricQ[FromOrderedPairs[A1]]
Out[127]=
True

In[128]:=
TransitiveQ[FromOrderedPairs[A1]]
Out[128]=
True

question 2
In[129]:=

P = {3, 5, 6, 8, 9, 11, 13}


Out[129]=

{3, 5, 6, 8, 9, 11, 13}

In[130]:=

GreaterEqualRelation[A _ : {_Integer}] := Select[Tuples[A, 2], GreaterEqual[#〚1〛, #〚2〛] &]


2

In[131]:=
T = GreaterEqualRelation[P]
Out[131]=
{{3, 3}, {5, 3}, {5, 5}, {6, 3}, {6, 5}, {6, 6}, {8, 3}, {8, 5}, {8, 6},
{8, 8}, {9, 3}, {9, 5}, {9, 6}, {9, 8}, {9, 9}, {11, 3}, {11, 5}, {11, 6}, {11, 8},
{11, 9}, {11, 11}, {13, 3}, {13, 5}, {13, 6}, {13, 8}, {13, 9}, {13, 11}, {13, 13}}

In[132]:=
Needs["Combinatorica`"]

In[133]:=
a = FromOrderedPairs[T]
Out[133]=
⁃ Graph:< 28,13,Directed >⁃

In[134]:=
ShowGraph[HasseDiagram[a], VertexLabel → True]
Out[134]=

11

1 2 4 7 10 12 13

Question 3
In[135]:=
DivideRelation[A _ : {_Integer}] := Select[Tuples[A, 2], Divisible[#〚2〛, #〚1〛] &]

In[136]:=
S = {4, 5};
X = {1, 2, 3, 4, 5, 6};
3

In[138]:=
Z = DivideRelation[X]
Out[138]=
{{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 2}, {2, 4}, {2, 6}, {3, 3}, {3, 6}, {4, 4}, {5, 5}, {6, 6}}

In[139]:=
MinimalElements[R _, S_List] := Module[{M, s, t}, M = S;
Do[
Do[If[MemberQ[R, {t, s}], M = Complement[M, {s}]], {t, Complement[S, {s}]}], {s, S}];
M]
In[140]:=
MinimalElements[Z, {4, 5}]
Out[140]=
{4, 5}

Question 4
In[141]:=
f[x_ , y _, z_] = (x ∧ y ∧ z) ∨ (! x ∧ y ∧ ! z) ∨ ((x ∨ y) ∧ (! x ∨ z))
Out[141]=
(x && y && z) || (! x && y && ! z) || ((x || y) && (! x || z))

In[142]:=
BooleanConvert[f[x, y, z], "CNF"]
Out[142]=
(! x || z) && (x || y)

Question 5
In[143]:=
A = {3, 4, 12, 24, 48, 72}
Out[143]=
{3, 4, 12, 24, 48, 72}

In[144]:=
dividerelation[A _ : {_Integer}] := Select[Tuples[A, 2], Divisible[#〚2〛, #〚1〛] &]

In[145]:=
B = dividerelation[A]
Out[145]=
{{3, 3}, {3, 12}, {3, 24}, {3, 48}, {3, 72}, {4, 4}, {4, 12}, {4, 24}, {4, 48}, {4, 72},
{12, 12}, {12, 24}, {12, 48}, {12, 72}, {24, 24}, {24, 48}, {24, 72}, {48, 48}, {72, 72}}

In[146]:=
a = FromOrderedPairs[B]
Out[146]=
⁃ Graph:< 19,72,Directed >⁃
4

In[147]:=
ShowGraph[HasseDiagram[a], VertexLabel → True]
Out[147]=

4872
24
12
12345678910
113
111
4151
6171
8292
021225
322
6272
8393
0313
233
4353
6373
8494
0414
24344
54649
755
0515
2535
455
6575
8696
0616
2636
46566
7687
9701

Question 6
(a)
In[148]:=
f[x_ , y _, z_] = (! x ∧ y) ∨ (y ∧ ! z) ∨ (y ∧ z) ∨ (x ∧ ! y ∧ ! z)
Out[148]=
(! x && y) || (y && ! z) || (y && z) || (x && ! y && ! z)

In[149]:=
f[x, y, z] // Simplify
Out[149]=
(x && ! z) || y

(b)
In[150]:=
g[x_ , y _, z_] = (x ∧ y ∧ z) ∨ (! x ∧ y ∧ ! z) ∨ ((x ∨ y) ∧ (! x ∨ z))
Out[150]=
(x && y && z) || (! x && y && ! z) || ((x || y) && (! x || z))

In[151]:=
BooleanMinimize[g[x, y, z]]
Out[151]=
(x && z) || (! x && y)

In[152]:=
BooleanMinimize[g[x, y, z], "CNF"]
Out[152]=
(! x || z) && (x || y)
5

In[153]:=
BooleanMinimize[g[x, y, z], "DNF"]
Out[153]=
(x && z) || (! x && y)

In[154]:=

In[155]:=

You might also like