0% found this document useful (0 votes)
35 views

LAB 04 FirstOrderLogic

Uploaded by

tchimed038
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

LAB 04 FirstOrderLogic

Uploaded by

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

Fundamentals of Artificial Intelligence

Laboratory

Dr. Mauro Dragoni

Department of Information Engineering and Computer Science


Academic Year 2021/2022
Exercise 8.12

Show using the propositional resolution calculus that:


(1) ¬C ∨ ¬D ∨ E
(2) F
(3) ¬D ∨ B
(4) ¬B ∨ A
(5) F ∨ E ∨ ¬A
(6) C ∨ B ∨ ¬G
(7) ¬C ∨ ¬A ∨ G
(8) ¬F ∨ ¬C ∨ D
(9) C
(10) ¬G

is not satisfiable;
page
02
Exercise 8.12
(1) ¬C ∨ ¬D ∨ E
(2) F
(3) ¬D ∨ B
(4) ¬B ∨ A
(5) F ∨ E ∨ ¬A
(6) C ∨ B ∨ ¬G
(7) ¬C ∨ ¬A ∨ G
(8) ¬F ∨ ¬C ∨ D
(9) C
(10) ¬G

(11) [(8), (2)] ⇒ (¬C ∨ D)


(12) [(9), (11)] ⇒ (D)
(13) [(12), (3)] ⇒ (B)
(14) [(13), (4)] ⇒ (A)
(15) [(9), (7)] ⇒ (¬A ∨ G)
(16) [(14), (15)] ⇒ (G) page
03
(17) [(10), (16)] ⇒ {}
Exercise 8.13

page
04
Exercise 8.13

¬C
B ∨ A ∨ C
¬A ∨ D
¬E ∨ ¬A ∨ F
¬E ∨ ¬F ∨ ¬A
G ∨ ¬A ∨ E
E ∨ ¬G ∨ ¬A
A ∨ H ∨ C
¬H ∨ ¬I ∨ A
I ∨ L ∨ M
¬L ∨ C ∨ ¬M
A ∨ ¬L ∨ M
L ∨ N ∨ ¬H
I ∨ L ∨ ¬N
page
05
Exercise 8.13

¬C
B ∨ A ∨ C
¬A ∨ D
¬E ∨ ¬A ∨ F
¬E ∨ ¬F ∨ ¬A
G ∨ ¬A ∨ E
E ∨ ¬G ∨ ¬A
A ∨ H ∨ C
¬H ∨ ¬I ∨ A
I ∨ L ∨ M
¬L ∨ C ∨ ¬M
A ∨ ¬L ∨ M
L ∨ N ∨ ¬H
I ∨ L ∨ ¬N
page
06
Exercise 9.1

▪ This exercise uses the predicates In(x, y), Borders (x, y), and Country(x), whose
arguments are geographical regions, along with constant symbols for various
regions. In each of the following we give an English sentence and a number of
candidate logical expressions.
For each of the logical expressions, state whether it (1) correctly expresses the
English sentence; (2) is syntactically invalid and therefore meaningless; or (3) is
syntactically valid but does not express the meaning of the English sentence.

a. Paris and Marseilles are both in France.

i. In(Paris ∧ Marseilles, France ).

ii. In(Paris, France ) ∧ In(Marseilles, France ).

iii. In(Paris, France ) ∨ In(Marseilles, France ).

page
07
Exercise 9.1

a. Paris and Marseilles are both in France.

i. In(Paris ∧ Marseilles, France).


(2) Syntactically invalid. Cannot use conjunction inside a term.

ii. In(Paris, France ) ∧ In(Marseilles, France).


(1) Correct.

iii. In(Paris, France ) ∨ In(Marseilles, France ).


(3) Incorrect. Disjunction does not express “both.”

page
08
Exercise 9.1

▪ This exercise uses the predicates In(x, y), Borders (x, y), and Country(x), whose
arguments are geographical regions, along with constant symbols for various
regions. In each of the following we give an English sentence and a number of
candidate logical expressions.
For each of the logical expressions, state whether it (1) correctly expresses the
English sentence; (2) is syntactically invalid and therefore meaningless; or (3) is
syntactically valid but does not express the meaning of the English sentence.

b. There is a country that borders both Iraq and Pakistan.

i. ∃c Country(c) ∧ Border(c, Iraq ) ∧ Border(c, Pakistan).

ii. ∃c Country(c) ⇒ [Border(c, Iraq ) ∧ Border(c, Pakistan)].

iii. [∃c Country(c)] ⇒ [Border(c, Iraq ) ∧ Border(c, Pakistan)].

iv. ∃c Border(Country(c), Iraq ∧ Pakistan). page


09
Exercise 9.1

b. There is a country that borders both Iraq and Pakistan.

i. ∃c Country(c) ∧ Border(c, Iraq) ∧ Border(c, Pakistan).


(1) Correct.

ii. ∃c Country(c) ⇒ [Border(c, Iraq) ∧ Border(c, Pakistan)].


(3) Incorrect. Use of implication in existential.

iii. [∃c Country(c)] ⇒ [Border(c, Iraq) ∧ Border(c, Pakistan)].


(2) Syntactically invalid. Variable c used outside the scope of its quantifier.

iv. ∃c Border(Country(c), Iraq ∧ Pakistan).


(2) Syntactically invalid. Cannot use conjunction inside a term.

page
010
Exercise 9.1

▪ This exercise uses the predicates In(x, y), Borders (x, y), and Country(x), whose
arguments are geographical regions, along with constant symbols for various
regions. In each of the following we give an English sentence and a number of
candidate logical expressions.
For each of the logical expressions, state whether it (1) correctly expresses the
English sentence; (2) is syntactically invalid and therefore meaningless; or (3) is
syntactically valid but does not express the meaning of the English sentence.

c. All countries that border Ecuador are in South America.

i. ∀c Country(c) ∧ Border(c, Ecuador ) ⇒ In(c, SouthAmerica).

ii. ∀c Country(c) ⇒ [Border(c, Ecuador ) ⇒ In(c, SouthAmerica)].

iii. ∀c [Country(c) ⇒ Border(c, Ecuador )] ⇒ In(c, SouthAmerica).

iv. ∀c Country(c) ∧ Border(c, Ecuador ) ∧ In(c, SouthAmerica). page


011
Exercise 9.1

c. All countries that border Ecuador are in South America.

i. ∀c Country(c) ∧ Border(c, Ecuador) ⇒ In(c, SouthAmerica).


(1) Correct.

ii. ∀c Country(c) ⇒ [Border(c, Ecuador) ⇒ In(c, SouthAmerica)].


(1) Correct. Equivalent to (i).

iii. ∀c [Country(c) ⇒ Border(c, Ecuador)] ⇒ In(c, SouthAmerica).


(3) Incorrect. The implication in the LHS is effectively an implication in an
existential; in particular, it sanctions the RHS for all non-countries.

iv. ∀c Country(c) ∧ Border(c, Ecuador) ∧ In(c, SouthAmerica).


(3) Incorrect. Uses conjunction as main connective of a universal quantifier.

page
012
Exercise 9.1

▪ This exercise uses the predicates In(x, y), Borders (x, y), and Country(x), whose
arguments are geographical regions, along with constant symbols for various
regions. In each of the following we give an English sentence and a number of
candidate logical expressions.
For each of the logical expressions, state whether it (1) correctly expresses the
English sentence; (2) is syntactically invalid and therefore meaningless; or (3) is
syntactically valid but does not express the meaning of the English sentence.

d. No region in South America borders any region in Europe.

i. ¬[∃c,d In(c, SouthAmerica ) ∧ In(d, Europe ) ∧ Borders(c, d)].

ii. ∀c,d [In(c, SouthAmerica) ∧ In(d, Europe )] ⇒ ¬Borders(c, d)].

iii. ¬∀c In(c, SouthAmerica ) ⇒ ∃d In(d, Europe ) ∧ ¬Borders(c, d).

iv. ∀c In(c, SouthAmerica) ⇒ ∀d In(d, Europe ) ⇒ ¬Borders(c, d). page


013
Exercise 9.1

d. No region in South America borders any region in Europe.

i. ¬[∃c,d In(c, SouthAmerica) ∧ In(d, Europe) ∧ Borders(c, d)].


(1) Correct.

ii. ∀c,d [In(c, SouthAmerica) ∧ In(d, Europe)] ⇒ ¬Borders(c, d)].


(1) Correct.

iii. ¬∀c In(c, SouthAmerica) ⇒ ∃d In(d, Europe) ∧ ¬Borders(c, d).


(3) Incorrect. This says there is some country in South America that borders
every country in Europe!

iv. ∀c In(c, SouthAmerica) ⇒ ∀d In(d, Europe) ⇒ ¬Borders(c, d).


(1) Correct.

page
014
Exercise 9.1

▪ This exercise uses the function MapColor and predicates In(x, y), Borders (x, y),
and Country(x), whose arguments are geographical regions, along with constant
symbols for various regions. In each of the following we give an English sentence
and a number of candidate logical expressions.
For each of the logical expressions, state whether it (1) correctly expresses the
English sentence; (2) is syntactically invalid and therefore meaningless; or (3) is
syntactically valid but does not express the meaning of the English sentence.

e. No two adjacent countries have the same map color.

i. ∀x,y ¬Country(x) ∨ ¬Country(y) ∨ ¬Borders(x, y) ∨ ¬(MapColor (x) = MapColor (y)).

ii. ∀x,y (Country(x) ∧ Country(y) ∧ Borders (x, y) ∧ ¬(x = y)) ⇒ ¬(MapColor (x) = MapColor
(y)).

iii. ∀x,y Country(x) ∧ Country(y) ∧ Borders(x, y) ∧ ¬(MapColor (x) = MapColor (y)).

iv. ∀x,y (Country(x) ∧ Country(y) ∧ Borders (x, y)) ⇒ MapColor (x = y). page
015
Exercise 9.1

e. No two adjacent countries have the same map color.

i. ∀x,y ¬Country(x) ∨ ¬Country(y) ∨ ¬Borders(x, y) ∨ ¬(MapColor (x) = MapColor (y)).


(1) Correct.

ii. ∀x,y (Country(x) ∧ Country(y) ∧ Borders (x, y) ∧ ¬(x = y)) ⇒ ¬(MapColor (x) = MapColor
(y)).
(1) Correct. The inequality is unnecessary because no country borders itself.

iii. ∀x,y Country(x) ∧ Country(y) ∧ Borders(x, y) ∧ ¬(MapColor (x) = MapColor (y)).


(3) Incorrect. Uses conjunction as main connective of a universal quantifier.

iv. ∀x,y (Country(x) ∧ Country(y) ∧ Borders (x, y)) ⇒ MapColor (x = y).


(2) Syntactically invalid. Cannot use inequality inside a term.

page
016
Exercise 9.2

▪ Consider a vocabulary with the following symbols:


Occupation(p, o): Predicate. Person p has occupation o.
Customer(p1, p2): Predicate. Person p1 is a customer of person p2.
Boss(p1, p2): Predicate. Person p1 is a boss of person p2.
Doctor, Surgeon, Lawyer, Actor: Constants denoting occupations.
Emily, Joe: Constants denoting people.

▪ Use these symbols to write the following assertions in first-order logic:

a. Emily is either a surgeon or a lawyer.


b. Joe is an actor, but he also holds another job.
c. All surgeons are doctors.
d. Joe does not have a lawyer (i.e., is not a customer of any lawyer).
e. Emily has a boss who is a lawyer.
f. There exists a lawyer all of whose customers are doctors.
g. Every surgeon has a lawyer.

page
017
Exercise 9.2

a. Emily is either a surgeon or a lawyer.


Occupation(Emily, Surgeon) ∨ Occupation(Emily, Lawyer).

b. Joe is an actor, but he also holds another job.


Occupation(Joe, Actor) ∧ ∃p p≠A ∧ Occupation(Joe, p).

c. All surgeons are doctors.


∀p Occupation(p, Surgeon) ⇒ Occupation(p, Doctor).

d. Joe does not have a lawyer (i.e., is not a customer of any lawyer).
¬∃p Customer(Joe, p) ∧ Occupation(p, Lawyer).

e. Emily has a boss who is a lawyer.


∃p Boss(p, Emily) ∧ Occupation(p, Lawyer).

f. There exists a lawyer all of whose customers are doctors.


∃p Occupation(p, Lawyer) ∧ ∀q Customer(q, p) ⇒ Occupation(q, Doctor).

g. Every surgeon has a lawyer.


∀p Occupation(p, Surgeon) ⇒ ∃q Occupation(q, Lawyer) ∧ Customer(p, q).
page
018
Exercise 9.3

▪ Consider a first-order logical knowledge base that describes worlds containing people,
songs, albums (e.g., “Meet the Beatles”) and disks (i.e., particular physical instances of
CDs). The vocabulary contains the following symbols:

CopyOf(d, a): Predicate. Disk d is a copy of album a.


Owns(p, d): Predicate. Person p owns disk d.
Sings(p, s, a): Album a includes a recording of song s sung by person p.
Wrote(p, s): Person p wrote song s.
McCartney, Gershwin, BHoliday, Joe, EleanorRigby, TheManILove, Revolver:
Constants with the obvious meanings.

Express the following statements in first-order logic:

a. Gershwin wrote “The Man I Love.”


b. Gershwin did not write “Eleanor Rigby.”
c. Either Gershwin or McCartney wrote “The Man I Love.”
d. Joe has written at least one song.
e. Joe owns a copy of Revolver.
f. Every song that McCartney sings on Revolver was written by McCartney.
page
019
Exercise 9.3

a. Gershwin wrote “The Man I Love.”


Wrote(Gershwin, TheManILove).

b. Gershwin did not write “Eleanor Rigby.”


¬Wrote (Gershwin, EleanorRigby).

c. Either Gershwin or McCartney wrote “The Man I Love.”


Wrote(Gershwin, TheManILove) ∨ Wrote(McCartney, TheManILove).

d. Joe has written at least one song.


∃s Wrote(Joe, s).

e. Joe owns a copy of Revolver.


∃x CopyOf(x, Revolver) ∧ Owns(Joe, x).

f. Every song that McCartney sings on Revolver was written by McCartney.


∀s Sings(McCartney, s, Revolver) ⇒ Wrote(McCartney, s).

page
020
Exercise 9.3

▪ Consider a first-order logical knowledge base that describes worlds containing people,
songs, albums (e.g., “Meet the Beatles”) and disks (i.e., particular physical instances of
CDs). The vocabulary contains the following symbols:

CopyOf (d, a): Predicate. Disk d is a copy of album a.


Owns(p, d): Predicate. Person p owns disk d.
Sings(p, s, a): Album a includes a recording of song s sung by person p.
Wrote(p, s): Person p wrote song s.
McCartney, Gershwin, BHoliday, Joe, EleanorRigby, TheManILove, Revolver:
Constants with the obvious meanings.

Express the following statements in first-order logic:

g. Gershwin did not write any of the songs on Revolver.


h. Every song that Gershwin wrote has been recorded on some album. (Possibly different
i. songs are recorded on different albums.)
j. There is a single album that contains every song that Joe has written.
k. Joe owns a copy of an album that has Billie Holiday singing “The Man I Love.”
l. Joe owns a copy of every album that has a song sung by McCartney. (Of course, each
m. different album is instantiated in a different physical CD.)
page
n. Joe owns a copy of every album on which all the songs are sung by Billie Holiday.
021
Exercise 9.3

g. Gershwin did not write any of the songs on Revolver.


¬[∃s Wrote(Gershwin, s) ∧ ∃p Sings(p, s, Revolver)].

h. Every song that Gershwin wrote has been recorded on some album. (Possibly different
songs are recorded on different albums.)
∀s Wrote(Gershwin, s) ⇒ ∃p,a Sings(p, s, a).

i. There is a single album that contains every song that Joe has written.
∃a ∀s Wrote(Joe, s) ⇒ ∃p Sings(p, s, a).

j. Joe owns a copy of an album that has Billie Holiday singing “The Man I Love.”
∃d,a,s CopyOf(d, a) ∧ Owns(Joe, d) ∧ Sings(BHoliday, TheManILove, a).

k. Joe owns a copy of every album that has a song sung by McCartney. (Of course, each
different album is instantiated in a different physical CD.)
∀a [∃s Sings(McCartney, s, a)] ⇒ ∃d CopyOf(d, a) ∧ Owns(Joe, d).

l. Joe owns a copy of every album on which all the songs are sung by Billie Holiday.
∀a [∀s,p Sings(p, s, a) ⇒ Sings(BHoliday, s, a)] ⇒ ∃d CopyOf(d, a) ∧ Owns(Joe, d).
page
022
Exercise 9.4

▪ Represent the following sentences in first-order logic, using a consistent


vocabulary (which you must define):

a. Some students took French in spring 2001.


b. Every student who takes French passes it.
c. Only one student took Greek in spring 2001.
d. The best score in Greek is always higher than the best score in French.
e. Every person who buys a policy is smart.
f. No person buys an expensive policy.
g. There is an agent who sells policies only to people who are not insured.
h. There is a barber who shaves all men in town who do not shave themselves.
i. A person born in the UK, each of whose parents is a UK citizen or a UK resident, is a UK
citizen by birth.
j. A person born outside the UK, one of whose parents is a UK citizen by birth, is a UK citizen
by descent.
k. Politicians can fool some of the people all of the time, and they can fool all of the people
some of the time, but they can’t fool all of the people all of the time.
l. All Greeks speak the same language. (Use Speaks(x, l) to mean that person x speaks
language l.)
page
023
Exercise 9.4

In this exercise, it is best not to worry about details of tense and larger concerns with consistent ontologies
and so on. The main point is to make sure students understand connectives and quantifiers and the use of
predicates, functions, constants, and equality. Let the basic vocabulary be as follows:

• Takes(x, c, s): student x takes course c in semester s;


• Passes(x, c, s): student x passes course c in semester s;
• Score(x, c, s): the score obtained by student x in course c in semester s;
• x > y: x is greater than y;

• F and G: specific French and Greek courses (one could also interpret these sentences as referring to any
such course, in which case one could use a predicate Subject(c, f ) meaning that the subject of course c
is field f;

• Buys(x, y, z): x buys y from z (using a binary predicate with unspecified seller is OK but less felicitous);
• Sells(x, y, z): x sells y to z;
• Shaves(x, y): person x shaves person y
• Born(x, c): person x is born in country c;
• Parent(x, y): x is a parent of y;
• Citizen(x, c, r): x is a citizen of country c for reason r;
• Resident(x, c): x is a resident of country c;
• Fools(x, y, t): person x fools person y at time t;

• Student(x), Person(x), M an(x), Barber(x), Expensive(x), Agent(x), Insured(x), Smart(x), Politician(x):


page
predicates satisfied by members of the corresponding categories.
024
Exercise 9.4

▪ Represent the following sentences in first-order logic, using a consistent


vocabulary (which you must define):

a. Some students took French in spring 2001.


∃x Student(x) ∧ Takes(x, F, Spring2001).

b. Every student who takes French passes it.


∀x,s Student(x) ∧ Takes(x, F, s) ⇒ Passes(x, F, s).

c. Only one student took Greek in spring 2001.


∃x Student(x) ∧ Takes(x, G, Spring2001) ∧ ∀y y≠x ⇒ ¬Takes(y, G, Spring2001).

d. The best score in Greek is always higher than the best score in French.
∀s ∃x ∀y Score(x, G, s) > Score(y, F, s).

e. Every person who buys a policy is smart.


∀x Person(x) ∧ (∃y,z Policy(y) ∧ Buys(x, y, z)) ⇒ Smart(x).

f. No person buys an expensive policy.


∀x,y,z Person(x) ∧ Policy(y) ∧ Expensive(y) ⇒ ¬Buys(x, y, z). page
025
Exercise 9.4

▪ Represent the following sentences in first-order logic, using a consistent


vocabulary (which you must define):

g. There is an agent who sells policies only to people who are not insured.
∃x Agent(x) ∧ ∀y,z Policy(y) ∧ Sells(x, y, z) ⇒ (Person(z) ∧ ¬Insured(z)).

h. There is a barber who shaves all men in town who do not shave themselves.
∃x Barber(x) ∧ ∀y Man(y) ∧ ¬Shaves(y, y) ⇒ Shaves(x, y).

i. A person born in the UK, each of whose parents is a UK citizen or a UK resident, is a UK


citizen by birth.
∀x Person(x) ∧ Born(x, UK) ∧ (∀y Parent(y, x) ⇒
((∃r Citizen(y, UK, r)) ∨ Resident(y, UK))) ⇒
Citizen(x, UK, Birth).

j. A person born outside the UK, one of whose parents is a UK citizen by birth, is a UK citizen
by descent.
∀x Person(x) ∧ ¬Born(x, UK) ∧ (∃y Parent(y, x) ∧ Citizen(y, UK, Birth)) ⇒
Citizen(x, UK, Descent).
page
026
Exercise 9.4

▪ Represent the following sentences in first-order logic, using a consistent


vocabulary (which you must define):

k. Politicians can fool some of the people all of the time, and they can fool all of the people
some of the time, but they can’t fool all of the people all of the time.
∀x Politician(x) ⇒
(∃y ∀t Person(y) ∧ Fools(x, y, t)) ∧
(∃t ∀y Person(y) ⇒ Fools(x, y, t)) ∧
¬(∀t ∀y Person(y) ⇒ Fools(x, y, t))

l. All Greeks speak the same language. (Use Speaks(x, l) to mean that person x speaks
language l.)
∀x,y,l Person(x) ∧ [∃r Citizen(x, Greece, r)] ∧ Person(y) ∧
[∃r Citizen(y, Greece, r)] ∧ Speaks(x, l) ⇒ Speaks(y, l)

page
027

You might also like