Sie sind auf Seite 1von 9

2/17/2020 SOFTWARE

ENGINEERING
LAB TASK 2
SUBMITTED TO: MAM AFNAN

Tesmia Shafiq

ROLL NUMBER: 190905


The Foundations: Logic and Proofs
EXERCISE 1.1
15) Let p, q, and r be the propositions
P: Grizzly bears have been seen in the area.
Q: Hiking is safe on the trail.
R: Berries are ripe along the trail.
Write these propositions using p, q, and r and logical connectives (including
negations).
a) Berries are ripe along the trail, but grizzly bears have not been seen in the area.
R^~P
b) Grizzly bears have not been seen in the area and hiking on the trail is safe, but
berries are ripe along the trail.
~P^Q^R
c) If berries are ripe along the trail, hiking is safe if and only if grizzly bears have not
been seen in the area.
R→ (Q ↔~P)
d) It is not safe to hike on the trail, but grizzly bears have not been seen in the area
and the berries along the trail are ripe.
~Q^~P^R
e) For hiking on the trail to be safe, it is necessary but not sufficient that berries not
be ripe along the trail and for grizzly bears not to have been seen in the area.
(Q→ (~R^P))^~ ((~R^~P) →~Q)
f) Hiking is not safe on the trail whenever grizzly bears have been seen in the area
and berries are ripe along the trail.
(P^R) → ~q

17. Determine whether each of these conditional statements is true or false.


a) If 1 + 1 = 2, then 2 + 2 = 5.
This conditional statement is false because p is true and q is false.

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.

D) If monkeys can fly, then 1 + 1 = 3.


This conditional statement is true because they are both false.
19. For each of these sentences, determine whether an inclusive or, or an
exclusive or, is intended. Explain your answer
a) Coffee or tea comes with dinner.
The diner gets to choose only one of the beverages so this is exclusive or.

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.

c) The prerequisite for the course is a course in number theory or a course in


cryptography.
The student may have both the courses so, inclusive or.

d) You can pay using U.S. dollars or euros.


The patron would pay a portion of the bill in dollars and the remainder in euros, 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.

b) The apple trees will bloom if it stays warm for a week.


 If it stays warm for a week, then the apple trees will bloom.

c) That the Pistons win the championship implies that they beat the Lakers.
If the Pistons win the championship, then they beat the Lakers.

d) It is necessary to walk 8 miles to get to the top of Long’s Peak.


If you get to the top of Longs Peak, then you must have walked 8 miles.

e) To get tenure as a professor, it is sufficient to be world-famous.


If you are world famous, then you will get tenure as a professor.

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.

h) Jan will go swimming unless the water is too cold.


If the water is not too cold, then Jan will go swimming.

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.

d) If you watch television your mind will decay, and conversely.


Your mind will decay if and only if you watch television.

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.

27. State the converse, contrapositive, and inverse of each of these


conditional statements.
a) If it snows today, I will ski tomorrow.
CONVERSE: If I will ski tomorrow, it snows today.
INVERSE: If it does not snows today, then I will not ski tomorrow.
CONTRAPOSITIVE: If I will not ski tomorrow, it does not snow today.

b) I come to class whenever there is going to be a quiz.


CONVERSE: There is going to be a quiz whenever I come to class.
INVERSE: I do not come to class whenever there is not going to be a quiz.
CONTRAPOSITIVE: There is not going to be a quiz whenever I do not come to class.

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.

33. Construct a truth table for each of these compound propositions.


a) (P ∨ q) → (p ⊕ q)
P Q (P ∨ q) (p ⊕ q) (P ∨ q) → (p ⊕ q)
T T T F F
T F T T T
F T T T T
F F F F T

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

39. Construct a truth table for (p ↔ q) ↔ (r ↔ s).

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

42. What is the value of x after each of these statements is encountered in a


computer program, if x = 1 before the statement is reached?
a) If x + 2 = 3 then x: = x + 1
x=2

b) If (x + 1 = 3) OR (2x + 2 = 3) then x: = x + 1
x=1

c) If (2x + 3 = 5) AND (3x + 4 = 7) then x: = x + 1


x=2

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

B) 1111 0000, 1010 1010


OR AND XOR
1111 1010 1010 0000 0101 1010

c) 00 0111 0001, 10 0100 1000


OR AND XOR
10 0111 1001 00 0100 0000 10 0011 1001

d) 11 1111 1111, 00 0000 0000


OR AND XOR
11 1111 1111 00 0000 0000 11 1111 1111

Das könnte Ihnen auch gefallen