Beruflich Dokumente
Kultur Dokumente
ENGINEERING
LAB TASK 2
SUBMITTED TO: MAM AFNAN
Tesmia Shafiq
b) If 1 + 1 = 3, then 2 + 2 = 4.
This conditional statement is true because p is false, but q is true, making it true.
c) If 1 + 1 = 3, then 2 + 2 = 5.
This conditional statement is true because p and q are both false.
b) A password must have at least three digits or be at least eight characters long.
Long passwords with many digits are acceptable so, inclusive or.
23. Write each of these statements in the form “if p, then q” in English. [Hint:
Refer to the list of common ways to express conditional statements.]
a) It snows whenever the wind blows from the northeast.
If the wind blows from the northeast, then it snows.
c) That the Pistons win the championship implies that they beat the Lakers.
If the Pistons win the championship, then they beat the Lakers.
f) If you drive more than 400 miles, you will need to buy gasoline.
If you drive more than 400 miles, then you will need to buy gasoline.
g) Your guarantee is good only if you bought your CD player less than 90 days ago.
If your guarantee is good, then you must have bought your CD player less than 90 days ago.
25. Write each of these propositions in the form “p if and only if q” in English.
a) If it is hot outside you buy an ice cream cone, and if you buy an ice cream cone it is
hot outside.
It is hot outside if and only if you buy an ice-cream cone.
b) For you to win the contest it is necessary and sufficient that you have the only
winning ticket.
You win the contest if and only if you have the winning ticket.
c) You get promoted only if you have connections, and you have connections only if
you get promoted.
You get promoted if and only if you have connections.
e) The trains run late on exactly those days when I take it.
The train runs late if and only if it is a day when I take the train.
c) A positive integer is a prime only if it has no divisors other than 1 and itself.
CONVERSE: A positive integer has no divisors other than 1and itself only if it is a prime.
INVERSE: A positive integer has not a prime only if it has divisor other than 1 and itself.
CONTRAPOSITIVE: A positive integer has divisors other than 1and itself only if it is not a
prime.
b) (P ⊕ q) → (p ∧ q)
P Q (P ⊕ q) (p ∧ q) (P ⊕ q) → (p ∧ q)
T T F T T
T F T F F
F T T F F
F F F F T
c) (P ∨ q) ⊕ (p ∧ q)
P Q (P ∨ q) (p ∧ q) (P ∨ q) ⊕ (p ∧ q)
T T T T F
T F T F T
F T T F T
F F F F F
d) (P ↔ q) ⊕ (¬p ↔ q)
P Q ~P (P ↔ q) (¬p ↔ q) (P ↔ q) ⊕ (¬p ↔ q)
T T F T F T
T F F F T T
F T T F T T
F F T T F T
e) (P ↔ q) ⊕ (¬p ↔ ¬r)
P Q R ~P ~R (P ↔ q) (¬p ↔ ¬r) (P ↔ q) ⊕ (¬p ↔
¬r)
T T T F F T T F
T T F F T T F T
T F T F F F T T
T F F F T F F F
F T T T F F F F
F T F T T F T T
F F T T F T F T
F F F T T T T F
f) (P ⊕ q) → (p ⊕ ¬q)
P Q ~Q (P ⊕ q) (p ⊕ ¬q) (P ⊕ q) → (p ⊕ ¬q)
T T F F T T
T F T T F F
F T F T F F
F F T F T T
37. Construct a truth table for each of these compound propositions.
a) P → (¬q ∨ r)
P Q R ~Q (¬q ∨ r) P → (¬q ∨ r)
T T T F T T
T T F F F F
T F T T T T
T F F T T T
F T T F T T
F T F F F T
F F T T T T
F F F T T T
b) ¬p → (q → r)
P Q R ~P (q → r) ¬p → (q → r)
T T T F T T
T T F F F T
T F T F T T
T F F F T T
F T T T T T
F T F T F F
F F T T T T
F F F T T T
c) (P → q) ∨ (¬p → r)
P Q R ~P (P → q) (¬p → r) (P → q) ∨ (¬p → r)
T T T F T T T
T T F F T T T
T F T F F T T
T F F F F T T
F T T T T T T
F T F T T F T
F F T T T T T
F F F T T F T
d) (P → q) ∧ (¬p → r)
P Q R ~P (P → q) (¬p → r) (P → q) ∧ (¬p → r)
T T T F T T T
T T F F T T T
T F T F F T F
T F F F F T F
F T T T T T T
F T F T T F F
F F T T T T T
F F F T T F F
e) (P ↔ q) ∨ (¬q ↔ r)
P Q R ~Q (P ↔ q) (¬q ↔ r) (P ↔ q) ∨ (¬q ↔ r)
T T T F T E T
T T F F T T T
T F T T F T T
T F F T F F F
F T T F F F F
F T F F F T T
F F T T T T T
F F F T T F T
f) (¬p ↔ ¬q) ↔ (q ↔ r)
P Q R ~P ~Q (¬p ↔ ¬q) (q ↔ r) (¬p ↔ ¬q) ↔ (q ↔ r)
T T T F F T T T
T T F F F T F F
T F T F T F F T
T F F F T F T F
F T T T F F T F
F T F T F F F T
F F T T T T F F
F F F T T T T T
p q r s (p ↔ q) (r ↔ s) (p ↔ q) ↔ (r ↔ s).
T T T T T T T
T T T F T F F
T T F T T F F
T T F F T T T
T F T T F T F
T F T F F F T
T F F T F F T
T F F F F T F
F T T T F T F
F T T F F F T
F T F T F F T
F T F F F T F
F F T T t T T
F F T F T F F
F F F T T F F
F F F F T T T
b) If (x + 1 = 3) OR (2x + 2 = 3) then x: = x + 1
x=1
d) If (x + 1 = 2) XOR (x + 2 = 3) then x: = x + 1
x=1
e) If x < 2 then x: = x + 1
x=2
If the hypothesis is TRUE than the conclusion result in x = 2.
If the hypothesis is FALSE than the conclusion is invalid and the result is x = 1
43. Find the bitwise OR, bitwise AND, and bitwise XOR of each of these pairs
of bit strings.
a) 101 1110, 010 0001
OR AND XOR
111 1111 000 0000 111 1111