Discrete Structures 1
Discrete Structures 1
Discrete Structures 1
Logic:The term "logic" came from the Greek word logos, which is sometimes translated as
"sentence", "discourse", "reason", "rule", and "ratio".we might define logic as the study of the
principles of correct reasoning.Logic examines the general forms which arguments may
take,which forms are valid and which are not.
Proposition:A proposition is a statement that is either true or false, but not both.
3. 1+1=2
4. 2+2=3
sentences 1 and 2 are not propositions because they are only statements.Sentences 3 and
4 are not propositions because they are neither true nor false,since the variables in these
sentences have not been assigned values.
“Today is Friday”
Note that thebiconditional p⟷q is true precisely when both the implications p→q and q→p
are true .Because of this the terminology
“p if and only if q” is used for biconditional.Other common ways of expressing the proposition p
⟷q are “p is necessary and sufficient for q” and “if p then q and conversely”
Bits: Computers represent information using bits. A bit has two possible values,namely 0 and 1.
A variable is called a Boolean Variable if its value is either true or false
6
Bit Strings:A bit string is a sequence of zero or more bits.The length of this string is the
number of bits in the string.
Note: x∨y=bitwise OR
x∧y=bitwise AND
x⊕y=bitwise XOR
Example: Find the bitwise OR,bitwise AND and bitwise XOR of the bit strings 01 1011 0110
and 11 0001 1101.
11 0001 1101.
Exercise 1.1:
Q1:Which of the following sentences are propositions?What are the truth values of thosethat are
propositions?
7
c) proposition,True d) proposition,False
Q2: Which of the following sentences are propositions?What are the truth values of those that
are propositions?
a) Do not pass go
b) What time is it?
c) There are no black flies in Maine.
d) 4+x=5
e) x+1=5 if x=1
f) x+y=y+z if x=z
Answer: a) No b) No c)yes
d)Noe)No f) No
a) Today is Thursday
Negation :Today is not Thursday
8
c) 2+1=3
Negation:2+1≠ 3
b) : I bought a lottery ticket this week or I won a million dollar jackpot on Friday
c): If I would have bought a lottery ticket this week I might have won a million dollar jackpot on
Friday
d) : I bought a lottery ticket this week and I won a million dollar jackpot on Friday
e) That I buy a lottery ticket this week is necessary and sufficient for me to win a million dollar
jackpot on Friday
f) If I have not bought a lottery ticket this week I would not have won a million dollar jackpot on
Friday
g) I did not buy a lottery ticket this week and I have not won a million dollar jackpot on Friday
9
h)I did not buy a lottery ticket this week or I bought a lottery ticket this week and I won a million
dollar jackpot on Friday
p: it is below freezing
q: it is snowing
a) p→q
Ans: If you have the flu then you’ll miss the final exam
b) ⇁q⟷ r
Ans:you do not miss the final exam if and only if you pass the course
c) q→ ⇁r
Ans: if you miss the final exam then you’ll not pass the course
d) p∨q∨r
Ans: : you have the flu or you miss the final exam or you pass the course
Ans:p→q
d) If you do not drive over 65 miles per hour then you’ll not get a speeding ticket
Ans: ⇁p→⇁q
e) Driving over 65 miles per hour is sufficient for getting a speeding ticket
Ans: p→q
f) you get a speeding ticket but you do not drive over 65 miles per hour
Ans: q⋀ ⇁p
g) Whenever you get a speeding ticket you are driving over 65 miles per hour
Ans: p→q
Contrapositive:if I will not ski tomorrow then it does not snow today.
Contrapositive: There is not going to be a quiz whenever I do not come to the class
c)A positive integer is prime only if it has no divisor other than 1 and itself
Converse: A positive integer has no divisor other than 1 and itself only if it is prime
Contrapositive: A positive integer has divisors other than 1 and itself only if it is not prime
a) p⋀ ⇁q
p q ⇁q p⋀ ⇁q
T T F F
T F T T
F T F F
F F T F
b) p∨⇁p
p ⇁p p∨⇁p
T F T
F T T
c) (p∨⇁q) →q
p q ⇁q p∨⇁q (p∨⇁q)
→q
13
T T F T T
T F T T F
F T F F T
F F T T F
e) (p∨q) → (p⋀q)
T T T T T
T F T F F
F T T F F
F F F F T
f) (p→q)⟷ (⇁ q →⇁p)
f) (p→q)→(q →p)
Q22: Construct a truth table for each of the following compound propositions
a) p⊕p
p p p⊕p
T T F
F F F
b)p⊕ ⇁p
p ⇁p p⊕ ⇁p
T F T
F T T
c) p⊕ ⇁q
p q ⇁q p⊕ ⇁q
T T F T
T F T F
F T F F
F F T T
d) ⇁p⊕ ⇁q
p q ⇁p ⇁q ⇁p⊕ ⇁q
15
T T F F F
T F F T T
F T T F T
F F T T F
e) (p⊕q)∨(p⊕ ⇁q)
T T F F T T
T F T T F T
F T F T F T
F F T F T T
a) (p⊕q)∧(p⊕ ⇁q)
T T F F T F
T F T T F F
F T F T F F
F F T F T F
T T T T T T T
T T T F T T F
T T F T T F T
T T F F T F T
T F T T F T T
T F T F F T F
T F F T F T T
T F F F F T F
F T T T T T T
F T T F T T F
F T F T T F T
F T F F T F T
F F T T T T T
F F T F T T F
F F F T T F T
F F F F T F T
Q29:Find the bitwise OR,bitwiseAND,bitwiseXORof each of the following pairs of bit strings
a) 1011110
0100001
bitwise OR 1111111
bitwise AND 0000000
bitwise XOR 1111111
b) 1011110
0100001
bitwise OR 1111111
bitwise AND 0000000
bitwise XOR 1111111
17
c) 0001110001
1001001000
bitwise OR 1001111001
bitwise AND 0001000000
bitwise XOR 1000111001
d) 1111111111
0000000000
bitwise OR 1111111111
bitwise AND 0001000000
bitwise XOR 1111111111
a) 11000 ∧(01011∨11011)
Solution:first we find (01011∨11011)
01011
∨11011
11011
then 11000 ∧(01011∨11011)= 11011
∧11000
11000
b) (01111∧10101)∨01000
Solution:first we find (01111 ∧ 10101)
01111
∧10101
00101
18
then(01111∧10101)∨01000= 00101
∨01000
01101
c) (01010⊕11011)⊕01000
Solution:first we find (01010⊕11011)
01010
⊕11011
10001
Then(01010⊕11011)⊕ 01000 = 10001
⊕01000
11001
and (10001∨11011)
10001
∨11011
11011