You are on page 1of 10

Name: Phm Vn Thng

Student ID: SE61092


Class: SE0767
Subject: Discrete Mathematics 1 (DM1)

ASSIGNMENT 1
PART 1
1. Exercises 50/ Page 20
Are these system specifications consistent? Whenever the system software is being upgraded, users
cannot access the file system. If user can access the file system, then they can save new file. If user
cannot save new files, then the system is not being upgraded.
Solution:
Let a denote whenever the system software is being upgraded.
Let b denote users can access the file system.
Let c denote they can save new files.
The specification can be written as:
Whenever the system software is being upgraded, users cannot access the file system a b


If user can access the file system, then they can save new file. b c
If user cannot save new files, then the system is not being upgraded. c a


We have truth tables:

a b c
a

a b


b c
c a


0 0 0 1 1 1 1 1 0
0 1 1 0 1 0 1 1 1
1 0 1 1 0 0 1 1 1
1 1 0 0 0 1 0 0 1

Because they are all true when a is false, b and c are true or a and c are true, b false. Hence, these
system specifications are consistent.

2. Exercises 36/ Page 29
When does s* = s, where s is a compound propositions.
Solution:
Let s = P(a
1
, a
2
, a
3
,, a
n
) where a
i
is a single proposition, and P is the relationship among a
i
.
So s* = (P)(a
1
, a
2
, a
3
,, a
n
) where (P) is the inverse relationship of P
s* = ((P)(a
1
, a
2
, a
3
,, a
n
) ) double negating
s* = ( P(a
1
, a
2
, a
3
,, a
n
) )
If s*= s
Then P(a
1
, a
2
, a
3
,, a
n
) = P(a
1
, a
2
, a
3
,, a
n
)
It means when we inverse every single proposition in s, if the truth value of s is also inversed,
proposition s is self-dual (or s*=s)

3. Exercises 30/ Page 48
Suppose the domain of the propositional function consists of pairs x and y, where x is 1, 2, or
3 and y is 1, 2, or 3. Write out these propositions using disjunctions and conjunctions.
a) ( , 3) x P x -
Solution:
(1, 3) (2, 3) (3, 3) P P P v v
b) (1, ) y P y
Solution:
(1,1) (1, 2) (1, 3) P P P . .
c) (2, ) y P y

-
Solution:
(2,1) (2, 2) (1, 3) P P P

v v
d) ( , 2) x P x


Solution:
(1, 2) (2, 2) (3, 2) P P P

. .


4. Exercises 24/ Page 61
Translate each of these nested quantifications into an English statement that expresses a mathematical
fact. The domain in each case consists of all real numbers.
a) ( ) x y x y y - + =
Solution:
There is a number that identify its sum with another number equal itself.
b) ((( 0) ( 0)) ( 0)) x y x y x y > . < >
Solution:
The subtraction of positive real number and negative real number is always a positive real number.
c) ((( 0) ( 0)) ( 0)) x y x y x y - - s . s . >
Solution:
There are exist 2 numbers that are negative real numbers and its subtraction is a positive real
number.
d) ((( 0) ( 0)) ( 0)) x y x y xy = . = =
Solution:
The multiplication of 2 numbers is non-zero if and only if each number is non-zero.

5. Exercises 10/ Page 73
For each of these sets of premises, what relevant conclusion or conclusions can be drawn? Explain
the rules of inference used to obtain each conclusion from the premises.
a) If I play hockey, then I am sore the next day. I use the whirlpool if I am sore. I did not use
the whirlpool.
Solution:
If I play hockey, then I am sore the next day.
I use the whirlpool if I am sore.
I did not use the whirlpool.
Where:
h: I play hockey.
s: I am sore.
w: I use the whirlpool.

1. w

Premise
2. s w Premise
3. s

Modus tollens from (1) and (2) I am not sore.


4. h s Premise
5. h w Hypothetical Syllogism from (2) and (4) If I play hockey, I use the whirlpool.
6. h

Modus tollens from (3) and (4) OR from (1) and (5) I did not play hockey.

b) If I work, it is either sunny or partly sunny. I worked last Monday or I work last Friday. It
was not sunny on Tuesday. It was not partly sunny on Friday.
Solution:
If I work, it is either sunny or partly sunny. 8x(W(x) ! (S(x) _ P(x)))
I worked last Monday or I worked last Friday. W(Monday) _W(Friday)
It was not sunny on Tuesday. :S(Tuesday)
It was not partly sunny on Friday. :P(Friday)
Where:
W(x): I work on x.
S(x): It is sunny on x.
P(x): It is partly sunny on x.
Domain for all is days of the week.

1. W(Monday) v W(Friday) Premise
2. ( ) ( ( ) ( )) W x S x P x v Premise
3. ( ) P Friday

Premise
4. ( ) ( ( ) ( )) W Monday S Monday P Monday v Universal instantiation from (2) If I work Monday
it is sunny or partly sunny on Monday.
5. ( ) ( ( ) ( )) W Friday S Friday P Firday v Universal instantiation from (2) If I work Friday it is
sunny or partly sunny on Friday.
6. ( ) ( ) W Friday S Friday Disjunctive syllogism from (3) and (5) If I work Friday it is sunny
on Friday.
7. ( ) ( ) ( ) ( ) S Monday P Monday S Friday P Friday v v v Modus ponens from (1), (4), and (6) It was
either sunny or partly sunny on Monday or sunny on Friday.

c) All insects have six legs. Dragonflies are insects. Spiders do not have six legs. Spiders eat
dragonflies.
Solution:
All insects have six legs. [ ( ) ( )] x I x L x
Dragonflies are insects. [ ( ) ( )] x D x I x
Spiders do not have six legs. [ ( ) ( )] x S x L x


Spiders eat dragonflies. (( ( ) ( ) ( , )) x S x D y E x y .
Where:
I(x): x is an insect.
D(x): x is a dragonfly.
L(x): x has six legs.
S(x): x is a spider.
E(x; y): x eats y.
Domain for all is {animals}.

1. [ ( ) ( )] x I x L x Premise
2. ( ) ( ) I c L c Universal instantiation from (1) If c is any insect then c has six legs.
3. ( ( ) ( )) x D x I x Premise
4. ( ) ( ) D x I x Universal instantiation from (3) (may use the same c since both are for all
statements and c is arbitrary) If c is any dragonfly then c is an insect.
5. ( ) ( ) D x L x Hypothetical syllogism from (2) and (4) If c is any dragonfly then c has six legs.
6. ( ( ) ( )) x D x L x Universal generalization from (5) All dragonflies have six legs, or just
Dragonflies have six legs."
7. ( ( ) ( )) x S x L x

Premise
8. ( ) ( ) S c L c

Universal instantiation from (7) If c is any spider then c does not have six legs.
9. ( ) ( ) L c I c

Contrapositive of (2) If any c does not have six legs then c is not an insect.
10. ( ) ( ) S c I c

Hypothetical syllogism from (8) and (9) If c is any spider then c is not an
insect.
11. ( ( ) ( )) x S c I c

Universal generalization from (10) All spiders are not insects, or just
Spiders are not insects."

d) Every student has an Internet account. Homer does not have an Internet account. Maggie has
an Internet account.
Solution:
Every student has an internet account. ( ( ) ( )) x S x I x
Homer does not have an internet account. ( ) I Homer


Maggie has an internet account. ( ) I Maggie


Where:
S(x): x is a student.
I(x): x has an internet account.
Domain for both is people.

1. ( ( ) ( )) x S x I x Premise
2. ( ) ( ) S Homer I Homer Universal instantiation from (1) If Homer is a student then Homer has
an internet account.
3. ( ) I Homer

Premise
4. ( ) S Homer

Modus tollen from (2) and (3) Homer is not a student.



e) All food that are healthy to eat do not taste good. Tofu is healthy to eat. You only eat what
tastes good. You do not eat tofu. Cheeseburgers are not healthy to eat.
Solution:
All foods that are healthy to eat do not taste good. ( ( ) ( )) x H x G x


Tofu is healthy to eat. ( ) H tofu
You only eat what tastes good. ( ( ) ( )) x E x G x
You do not eat tofu. ( ) E tofu


Cheeseburgers are not healthy to eat. ( ) H cheesburger


H(x): x is healthy to eat.
G(x): x tastes good.
E(x): You eat x.

Domain for all is {foods}.
1. ( ( ) ( )) x H x G x

Premise
2. ( ) ( ) H tofu G tofu

Universal instantiation from (1)


3. ( ) H tofu Premise
4. ( ) G tofu

Modus ponens from (2) and (3) Tofu does not taste good.
5. ( ( ) ( )) x E x G x Premise
6. ( ) ( ) E c G c Universal instantiation from (5) If you eat any food c it tastes good and if an food
c tastes good you eat it.
7. ( ) ( ) H c G c

Universal instantiation from (1) Any food c that is healthy does not taste good.
8. ( ) ( ) E c G c

Contrapositive of (6)
9. ( ) ( ) H c E c

Hypothetical syllogism from (7) and (8) If any food c is healthy you don't eat it.
10. ( ( ) ( )) x H x E x

Universal generalization from (9) You don't eat healthy foods.



f) I am either dreaming or hallucinating. I am not dreaming. If I am hallucinating, I see
elephants running down the road.
Solution:
I am either dreaming or hallucinating. d h v
I am not dreaming. d


If I am hallucinating, I see elephants running down the road. h e
Where:
d: I am dreaming.
h: I am hallucinating.
e: I see elephants running down the road.

1. d

Premise
2. d h v Premise
3. h Disjunctive syllogism I am hallucinating.
4. h e Premise
5. e Modus ponens from (3) and (4) I see elephants running down the road.

6. Exercises 2/ Page 85
Use the direct proof to show that the sum of two even integers is even.
Solution:
So assume that the two numbers A and B are even integers. Then A and B can be written in the forms
A = 2i, for some integer i, and B = 2j, for some integer j.Then, (A + B) = (2i + 2j) = 2 . (i + j) Since i
and j are integers, so is (i + j), and if you assign the letter k to the integer (i + j), then (A + B) = 2k,
which is a member of the set of even integers as we described at the beginning.

7. Exercises 38/ Page 103
Verify the 3 1 x + conjecture for these integers:
a) 16
The conjecture for 16 is:
16 8 4 2 1
b) 11
The conjecture for 11 is:
11 34 17 52 26 13 40 20 10 5 16 8 4 1
c) 35
The conjecture for 35 is:
35 106 53 160 80 40 20 10 5 16 8 4 2 1
d) 113
The conjecture for 113 is:
113 340 170 85 256 128 64 32 16 8 4 2 1


8. Exercises 8/ Page A-6
Prove that for all real numbers x and y, x y = if and only if 0 x y = .
Solution:
We have:
( ) ( ) 0 x y x y + + + = ; and
( ) ( ) ( ) ( ) ( ) 0 0 0 x y x y x x y y + + + = + + + = + =
Thus,
( ) ( ) ( ) x y x y x y + = + = .
Inclusion:
Inverse of x y is ( ) ( ) x y x y x y = = + ;
( ) ( ) 0 x y x y + + = (1) Inverse law for addition

Case 1: x y =
We have:
( ) 0 x x + = Inverse law for addition
( ) 0 y x + =
0 x y + = (2)
(1) and (2):
( ) 0 0 x y + =
0 x y = Additive Identity

Case 2: 0 x y =
We have:
0 x x + = (3) Inverse law for addition
From (1) ( ) ( ) 0 x y x y + + = ;
0 ( ) 0 x y + + =
0 x y + = (4) Additive Identity
(3) and (4):
0
0
x x
x y
+ =

+ =

; x and y are inverse of ( ) x x y =



Hence, if and only if 0 x y x y = = .

9. Exercises 24/ Page 120
What is the Cartesian product A B , where A is the set of courses offered by the mathematics
department at a university and B is the set of mathematics professors at this university?
Solution:
The Cartesian Product is the set of ( , ) x y where x is the mathematics department at a university and
y is the set of mathematics professors at this university.


10. Exercises 38/ Page 131
Show that if A and B are sets, then
a) A B B A =
Proof:
( ) ( ) A B x A x B x A x B = e . e v e . e

( ) ( ) ( ) ( ) B A x B x A x B x A x A x B x A x B = e . e v e . e = e . e v e . e

Hence,
A B B A =
b) ( ) A B B A =
Proof:
( ) (( ) ( )) [(( ) ( )) ] [(( ) ( )) ]
( ) ( )
A B B A B A B B A B A B B A B A B B
A B B A A
= =
= =

Hence,
( ) A B B A =


11. Exercises 46/ Page 148
Show that if x is a real number and m is an integer, then x m x m + = +

Proof:
We have:
a x b < s where a and b are integer numbers.
So, x b = .(1)
If a m x m b m + < + s + , then x m b m + = + (2)
From (1) and (2): x m x m + = +

12. Exercises 16/ Page 161
Find the value of each of these sums:
a)
8
0
(1 ( 1) )
j
j =
+


Solution:

8
1 2 8
0
(1 ( 1) ) (1 ( 1) ) (1 ( 1) ) ... (1 ( 1) ) 10
j
j =
+ = + + + + + + =


b)
8
0
(3 2 )
j j
j =


Solution:

8
1 1 2 2 8 8
0
(3 2 ) (3 2 ) (3 2 ) ... (3 2 ) 9330
j j
j =
= + + + =


c)
8
0
(2 3 3 2 )
j j
j =
+


Solution:

8
1 1 2 2 8 8
0
(2 3 3 2 ) (2 3 3 2 ) (2 3 3 2 ) ... (2 3 3 2 ) 18149
j j
j =
+ = + + + + + + =


d)
8
0
(2 2 )
j i j
j
+
=


Solution:
8
1 1 2 2 8 8
0
(2 2 ) (2 2 ) (2 2 ) ... (2 2 ) 511
j i j i i i
j
+ + + +
=
= + + + =




PART 2

// AS1_DM1.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <iostream>
using namespace std;

void initDomain(int s[]);
void input(int s1[]);
void output(int s[]);
void AnB(int s1[],int s2[],int s3[]);
void AorB(int s1[],int s2[],int s3[]);
void AmB(int s1[],int s2[],int s3[]);
void AxorB(int s1[],int s2[],int s3[]);
void notA(int s1[],int s3[]);
int _tmain(int argc, _TCHAR* argv[])
{
int s1[101], s2[101], s3[101];
initDomain(s1);
initDomain(s2);
initDomain(s3);
cout << "Enter set A" << endl;
input(s1);
output(s1);

cout << "Enter set B" << endl;
input(s2);
output(s2);

cout << "========Result======= " << endl;
cout << " ------A AND B----- " << endl;
AnB(s1,s2,s3);
output(s3);

cout << " ------A OR B------ " << endl;
AorB(s1,s2,s3);
output(s3);

cout << " ----- A - B ------ " << endl;
AmB(s1,s2,s3);
output(s3);

cout << " ------A XOR B----- " << endl;
AxorB(s1,s2,s3);
output(s3);

cout << " ------ NOT A ----- " << endl;
notA(s1,s3);
output(s3);

return 0;
}
void initDomain(int s[])
{
for (int i=0;i<=101;i++)
s[i]=1;
};
void input(int s[])
{
int n, i;
for (i=0;i<102;i++) s[i]=0; // clearing the int
cout << "Enter number of elements:";
cin >> n;
cout << "Enter values 0..100 :";
for (int i=0;i<n;i++)
{
int x;
cin >> x;
if ((x>=0) && (x<=100))
{
s[x]=1;
}
}
}

void output(int s[])
{
cout << "{ " ;
for(int i=0;i<101;i++)
if (s[i]==1)
cout << i << " ";
cout << "}" << endl;
}

void AnB(int s1[],int s2[],int s3[])
{
for(int i=0;i<101;i++)
s3[i]=0;
for(int j=0;j<101;j++)
s3[j]=s1[j]*s2[j];
}

void AorB(int s1[],int s2[],int s3[])
{
for(int i=0;i<101;i++)
{
s3[i]=0;
if((s1[i]==1)||(s2[i]==1))
s3[i]=1;
}
}

void AmB(int s1[],int s2[],int s3[])
{
for(int i=0;i<101;i++)
{
s3[i]=0;
if (s1[i]==s2[i])
s3[i]=0;
else
s3[i]=s1[i];
}
}

void AxorB(int s1[],int s2[],int s3[])
{
for(int i=0;i<101;i++)
{
s3[i]=0;
if(s1[i]!=s2[i])
s3[i]=1;
}
}

void notA(int s1[],int s3[])
{
for(int i=0;i<101;i++)
if(s1[i]==1)
s3[i]=0;
else
s3[i]=1;
}

// DEMO 1



















// DEMO 2

You might also like