Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

COMSATS UNIVERSITY ISLAMABAD, LAHORE CAMPUS

Assignment 01: Formal Methods

Name: Hamza Khan (FA22-BSE-064)

CLASS: BSE-4A

COURSE: CSE356

SUBMITTED TO: Dr. Farooq Ahmad

Question 1: Can you switch the order of quantifiers? For example, consider the two statements:
∀x∃yP (x, y) and ∃y∀xP (x, y) Are these logically equivalent? Justify your point in
detail.
Answers:
∀x∃yP (x, y): The given statement is about that for every x there is y for which
value is true.
Justification: Let P (x, y) be the statement "x is the parent of y."
The statement: ∀x∃yP (x, y) could be interpreted as "For every person x, there
exists a person y who is their child."
∃y∀xP (x, y): The given statement is about there is y for which every x is true.
Justification: Let’s take an example that x=0 and y= N and p (x, y) = (x<=y)
than this statement is true for this case.

Conclusion: So, the conclusion is both statements are different by their logic, so they are
not equivalent.

Question 2: Use ¬, →, ∧, ↔ and ∨ to express the following declarative sentences in propositional


logic; in each case state what your respective propositional atoms p, q, etc.
If it rains while the sun shines, a rainbow will appear.

P=It rains q=the sun shines r=rainbow appear


(p ∧ q) → r

Charles comes if Elsa does and the other way around.


Let
C: "Charles comes."
E: "Elsa comes."
(C ↔ E)
Johan comes just when Peter stays at home.
p=Johan comes q=Peter stays at home
(q→p)

We are going unless it is raining.


p=We are going q=it is raining
¬q → p
Charles and Elsa are brother and sister or nephew and niece.
p=Charles and Elsa are brother and sister. q=Charles and Elsa are nephew and
niece.
(p ∨ q)

If I have lost if I cannot make a move, then I have lost.


p= I have lost q= I cannot make a move
(¬p → q) → q

Question 3: Consider the statement about a party, “If it's your birthday or there will be cake, then
there will be cake. “Use Preposition Logic to present the following statements.

Translate the above statement into symbols. Clearly state which statement is P and which
is Q.
p= It's your birthday. q=There will be cake.
(p ∨ q) →q
Make a truth table for the statement.
p q p∨q (p ∨ q) →q

T T T T
T F T F
F T T T
F F F T

Assuming the statement is true, what (if anything) can you conclude if there will be cake?
The given scenario is if there will be a cake means this statement is always true to
make whole statement true.

Assuming the statement is true, what (if anything) can you conclude if there will not be cake?
Then the given scenario cannot be true in any case because if q becomes false the
statement automatically becomes false.

Suppose you found out that the statement was a lie. What can you conclude?
So given scenario is negating one of the statements means either its not your birthday or there
will not be cake.

Question 4: We can simplify statements in predicate logic using our rules for passing negations over
quantifiers, and then applying propositional logical equivalence to the “inside” propositional part.
Simplify the statements below (so negation appears only directly next to predicates).
¬∃x∀y (¬O(x)∨E(y)).
∀x∃y¬(¬O(x)∨E(y))
∀x∃y(O(x)∧¬E(y))

¬∀x¬∀y¬(x<y∧∃z(x<z∨y<z)).
∃x¬¬∀y¬(x<y∧∃z(x<z∨y<z))
∃x∀y¬¬(x<y∧∃z(x<z∨y<z))
∃x∀y(x<y∧¬∃z(x<z∨y<z))
∃x∀y (x≥y∨∀z¬ (x≥z∧y≥z))
∃x∀y(x≥y∨∀z(x≥z∧y≥z))

There is a number n for which no other number is either less n than or equal to n.
Means there is a number n which is always smaller than for every number m.

∃n∀m(m>n)

It is false that for every number n there are two other numbers which n is between.
¬(∀n∃x∃y(x<n<y))

Question 5: Formulate the following English sentences as formulae in classical 1st-order logic.
All purple mushrooms are poisonous.
∀x (Purple(x) ∧ Mushroom(x) → Poisonous(x))

No student likes every lecture.


¬∀x∀y (Student(x) ∧ Lecture(y) → Likes(x, y))

Everest is the highest mountain on Earth.


∃x∀y (Everest(x) ∧ Earth(y) → Highest(x))

There are at least two apples in a barrel.


∃x∃x∃z [Apple(x) ∧ Apple(y) ∧ ¬ (x = y) ∧ Barrel(z) ∧ ln(x,z) ∧ ln(y,z)]

There are at least two apples in every barrel.


∀z (Barrel(z) → ∃x ∃y (Apple(x) ∧ Apple(y) ∧ ¬(x = y) ∧ ln(x, z) ∧ ln(y, z)))
x is part of y just in case everything that is connected to x is also connected to y (this is a
fundamental definition used in certain theories of spatial relations).
∀x ∀y (Part (x, y) ↔ ∀z (Connected(x, z) → Connected(y, z)))

No region is part of each of two disjoint regions.


¬∃r (∃s ∃t (Region(r) ∧ Disjoint(s, t) ∧ Part(r, s) ∧ Part(r, t)))
Nothing can be inside two different boxes unless one box is inside the other.
¬∃o ∃b1 ∃b2 (Inside(o, b1) ∧ Inside(o, b2) ∧ ¬Disjoint(b1, b2) ∧ ¬Disjoint(b2, b1))

You might also like