100% found this document useful (1 vote)
2K views

Examples of Fol

This document provides examples of converting statements between natural language and first-order logic. It includes examples of quantifiers like ∀ (for all) and ∃ (there exists), logical connectives like ⇒ (implies) and ∧ (and), and predicates. The document tests the ability to correctly write statements in first-order logic that correspond to given English descriptions, and vice versa. It also includes questions to test understanding of concepts like validity, scope of quantifiers, and the difference between ∧ and ⇒.

Uploaded by

Kuldeep Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views

Examples of Fol

This document provides examples of converting statements between natural language and first-order logic. It includes examples of quantifiers like ∀ (for all) and ∃ (there exists), logical connectives like ⇒ (implies) and ∧ (and), and predicates. The document tests the ability to correctly write statements in first-order logic that correspond to given English descriptions, and vice versa. It also includes questions to test understanding of concepts like validity, scope of quantifiers, and the difference between ∧ and ⇒.

Uploaded by

Kuldeep Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

First-Order Logic Practice Questions & Answers

This exercise is not graded and you will not turn it in. These are practice questions (done and discussed in-class)
to get you used to writing in first order logic.
Convert to English
1. x IsABunny(x) IsCute(x)
All bunnies are cute
2. x IsAStudent(x) IsTakingAI(x) IsCool(x)
Everyone student who is taking AI is cool
3. x IsABunny(x) IsAStudent(x) IsTakingAI(x) IsCute(x) IsCool(x)
Every bunny who is a student taking AI is cute and cool
4. x EatsRamen(x) IsHomeless(x) IsAGradStudent(x)
Everyone who eats ramen is either homeless or a graduate student
5. s h IsAStudent(s) IsTaking(s,AI) HomeworkFor(h,AI) Hates(s,h)
There is at least one student who doesnt hate (any of) the AI homework
6. a (IsACat(a) Rules(a)) (IsADog(a) Drools(a))
Cats rule and dogs drool
7. p time base isACaptain(captain) isABase(base) <(time, Now)
Owns(captain, base, time) Owns(CATS, base, Now)
All the bases that belonged to Captain now belong to CATS
8. =(2,2)
2=2
9. +(2, 2) 4
2+2=4
10.
2+2=4

2 + 2 4

Convert to English and Predicate Calculus


11. Convert to English and FOL
for (i=0; i<numObjects; i++)
{
Object x = Objects(i);
if isMushroom(i)
if isPoisonous(x) && isPurple(x)
return false;
}
return true;
There are no mushrooms that are poisonous and purple
x Mushroom(x) (Poisonous(x) Purple(x))
12. Convert to English and FOL
for (i=0; i<numObjects; i++)
{
Object x = Objects(i);
if isMushroom(i) && isPoisonous(x) && isPurple(x)
return true;
}
return false;
There is a mushroom that is purple and poisonous
x Mushroom(x) Poisonous(x) Purple(x)

Convert to First-Order Logic


13. There is a bunny who is a cute
x IsABunny(x) IsCute(x)
14. Elder gods do not like Hello Kitty
x IsAnElderGod(x) Likes(x, HelloKitty)
15. Sister-in-law (your spouses sister)
x,y SisterInLaw(x,y) z Female(x) Spouse(y,z) Siblings(x,z)
16. There is only one Elvis (do not use !)
x IsElvis(x) y IsELvis(y) x=y
In class there was some discussion as to whether the approach i showed in class was correct. As everyone
figured, it wasnt (i was comparing predicates, which are bools, instead of objects). Above is the correct syntax.
17. Every child who has a Chinpokomon card is cool
x,y Child(x) ChinpokomonCard(y) Owns(x,y) Cool(x)

18. Some students took AI1 in Spring 2008 (using Take(person, course, semester))
x Student(x) Takes(x, AI1, Spring2008)
19. Every student who takes AI1 passes it
x,y Student(x) Semester(y) Takes(x, AI1, y) Passes(x, AI1, y)
The y in the above sentence (the semester the course was taken) is used because we defined our predicate to
take a time parameter in question 18. Including it with Passes wasnt necessary but was done the same way for
consistency.

First-Order Logic Practice Questions


Second Wave
In the sentences below, a symbol is missing. What symbol is it most likely to be?
20. x Something(x) ??? SomethingElse(x)

The general rule is, goes with , goes with . The questions in the next section show why.
21.

x Something(x)

???

SomethingElse(x)

The general rule is, goes with , goes with . Questions 24-27 show why.

Is this correctly written?


22. Peter has at least two children.
x,y ParentOf(Peter, x) ParentOf(Peter, y)
No.
Consider the array of kids [Alice, Bob, Charles]. Peter is the father of Alice and no one else. Now consider the
equivalent C (pseudo)code
//--- Look for first match
for (x=0; x<numKids; x++)
if isParent(Peter, kids[x])
match1Found = true;
//--- Now look for a second match
for (y=0; y<numKids; y++)
if isParent(Peter, kids[y])
match2Found = true;
return match1Found && match2Found;
The first loop will find Alice (x ParentOf(Peter, x)) at x=0 and the second loop will also find Alice
(x ParentOf(Peter, y)) at y=0. Youve basically double-counted someone. The universal and
existential quantifiers loop through all objects to match a variable and do so independently of any other
quantifier or variable. If you dont want to double count something, you have to check for it yourself. So the
correct version of the above is
x,y ParentOf(Peter, x) ParentOf(Peter, y) (x=y)
23. Someone at Stanford is smart
x At(x, Stanford) isSmart(x)
Yes, this one is fine.

Convert to English
24. x At(x, Berkeley) isSmart(x)
Everyone at Berkeley is smart.
If youre wondering why i used Berkeley its because this is one of the rare occasions that i used someone elses
example, in this case Russel and Norvig. You can guess what school one of the authors is from.
25.

x At(x, Berkeley) isSmart(x)

Everyone is at Berkeley. Everyone is smart.


This is probably not what you wanted to write. Its also a very common mistake. Remember use with ,
not .
26.

x At(x, Stanford) isSmart(x)

Contrary to what many people think, this statement does not say that there is a person at Stanford who is smart.
It says that if there is at least one person who, if he is at Stanford, is also smart. And if he isnt, who knows.
While its possible the author meant this, in most cases this is an error. Remember use with , not .
Applying implication elimination, you could also write:
x At(x, Stanford) isSmart(x)
which means there exists at least one person who either doesnt go to Stanford or who is smart (whether hes at
Stanford or not).
If you build a truth table for this statement youll find that it is false when someone attends Stanford and none
of them are smart and is true all other times - if there is someone at Stanford who is smart and if nobody attends
Stanford. Implicative rules are always true if the antecedent the if part is false, with the reasoning that you
cant test the rule and as a result cant violate it.
27.

x At(x, Stanford) isSmart(x)

There is someone who goes to Stanford and is smart.


Presumably this was Maria. But shes here now so we can no longer verify that the above sentence is true.
28.

x,y Loves(x, y)

Everybody loves everybody


29.

x y Loves(x, y)

Everyone loves at least one person.

30.

x y Loves(x, y)

There is at least one person who loves everyone


Hopefully youve noticed that the above three sentences are identical other than the quantifiers.

Are these valid? (remember, valid = always true)


31. x y Loves(x, y) x y Loves(x, y)
The question is asking, is everyone loves someone the same as there is at least one person who loves
everybody. While this is satisfiable, it is not valid.
32.

x Loves(x, Snoopy) x Loves(x, Snoopy)

This question is asking, is everyone loves Snoopy the same as there is not a single person who doesnt love
Snoopy. These are exactly the same thing.
In general, x P(x) and x P(x) are equivalent. But one is shorter to write.
33.

x Loves(x, AmericanIdol) x Loves(x, AmericanIdol)

This question is asking, is there is at least one person who loves American Idol the same as not everybody
hates American Idol (assuming you consider not loves and hate to be the same thing; it sounds better than not
everyone doesnt love American Idol). These are exactly the same thing.
In general, x P(x) and x P(x) are equivalent. But one is shorter to write.
34.

x,y P(x, y) P(y, x)

This question is asking, are all predicates P(x,y) the same as P(y,x) (the same statement with arguments
reversed). This is not valid (i.e., always true). For example, reversing the arguments isnt important in
Sibling(Meg, Chris) and Sibling(Meg, Chris) but is it for Parent(Peter, Meg) and
Parent(Meg, Peter).
35.

x,y x=y

Yes, this is valid (always true).


Is there at least one value for x that is the same as the value for y? As mentioned in question 22, x and y could
represent the exact same variable. If our set of objects is [apple, orange], looping through all of the objects will
make x=apple once and y=apple once.
36.

x,y x=y

Is every single object the exact same as every other object? Normally, no. If you have only one object in the
world, this would be true but otherwise this is unsatisfiable.

Convert to First-Order Logic


37. Blue databases are better than other databases
x,y Database(x) Database(y) IsBlue(x) IsBluex(y) x > y
This sentence makes absolutely no sense. But thats OK. As long as you follow the rules of formal logic land,
formal logic does not mind if what youve written makes no sense in the real world.
38. All numbers are bigger than themselves divided by two
x x > (x/2)
39. Great-grandfather (define using three predicates)
gg,c GreatGrandDad(gg,c) g,p Parent(gg,g) Parent(g,p) Parent(p,c)
40. Great-grandfather (define using one predicate; you can make other predicates)
gg,c GreatGrandDad(gg,c) g Parent(gg, GrandParent(g,c)
g,c GrandDad(gg,c) p Parent(g,p) Parent(p,c)
41. First cousin (child of your parents siblings)
x,y FirstCousin(x,y) p,ps Siblings(ps,p) Parent(p,x) Parent(ps,y)
42. All grad students watch the same TV shows
x,y,s GradStudent(x) GradStudent(y) Watches(x,s) Watches(y,s)
Technically, grad students should not be watching TV. You people have work to do.
43. Only one student took AI2 in Fall 2008
x Student(x) Takes(x, AI2, F08) y (yx Takes(y, AI2, F08))
44. The best score in AI2 is always higher than the best score in AI1
semester x y Score(x, AI2, semester) > Score(y, AI1, semester)
45. Any person can fool some of the people all of the time, all of the people some of the time but not all of the
people all of the time
x Person(x)
(y t
(t y
(t y

Person(y) Fools(x,y,t))
Person(y) Fools(x,y,t))
Person(y) Fools(x,y,t))

You might also like