Logic PDF
Logic PDF
Logic PDF
But that fails to capture the relationship between any individual being a man and that
individual being a mortal. To do that, we really need variables and quantification unless we are willing
to write separate statements about the mortality of every known man.
Let's now explore the use of predicate logic as a way of representing
knowledge by looking at a specific example. Consider the following set of
sentences:
1 . Marcus was a man.
2. Marcus was a Pompeian.
3. All Pompeians were Romans.
4. Caesar was a ruler.
5. All Romans were either loyal to Caesar or hated him.
6. Everyone is loyal to someone.
7. People only try to assassinate rulers they are not loyal to.
8. Marcus tried to assassinate Caesar.
The facts described by these sentences can be represented as a set of wff's in predicate logic as
follows:
1 . Marcus was a man.
man(Marcus)
2. Marcus was a Pompeian.
Pompeian(Marcus)
3. All Pompeians were Romans.
∀x: Pompeian(x) → Roman(x)
4. Caesar was a ruler.
ruler(Caesar)
5. All Romans were either loyal to Caesar or hated him.
∀x: Roman(x) → loyalto(X. Caesar) V hate(x, Caesar)
6. Everyone is loyal to someone.
∀x : ∃ y : Ioyalto(x,y)
7. People only try to assassinate rulers they are not loyal to.
∀ x : ∀ y : person(x) ∧ ruler(y) ∧ tryassassinate(x,y) → ¬ Ioyalto(x,y)
8. Marcus tried to assassinate Caesar.
tryassassinate (Marcus, Caesar)
9. All men are people.
∀x : man(x) → person(x)
Now suppose that we want to use these statements to answer the question
Was Marcus loyal to Caesar?
The next example shows how these ideas of computable functions and predicates
can be useful. Consider the following set of facts, again involving Marcus:
I. Marcus was a man.
man(Marcus)
2. Marcus was a Pompeian.
Pompeian(Marcus)
3. Marcus was born in 40 A.D.
born(Marcus, 40)
4. All men are mortal.
∀x: man(x) → mortal(x)
5. All Pompeians died when the volcano erupted in 79 A.D.
erupted(volcano, 79) ∧ ∀ x : *Pompeian(x) → died(x, 79)+
6. No mortal lives longer than 150 years.
∀x: ∀t1: At2: mortal(x) ∧ born(x, t1) ∧ gt(t2 - t1,150) → dead(x, t2)
7. It is now 1991.
now = 1991
8. Alive means not dead.
∀x: ∀t: *alive(x, t) → ¬ dead(x,t)] ∧ *¬ dead(x, t) → alive(x, t)+
9. If someone dies, then he is dead at all later times.
∀x: ∀t1: At2: died(x, t1) ∧ gt(t2, t1) → dead(x, t2)
Now let's attempt to answer the question "Is Marcus alive?" by proving:
¬ alive(Marcus, now)
Conversion to Clause form
Suppose we know that all Romans who know Marcus either hate Caesar or
think that anyone who hates anyone is crazy. We could represent that in the
following wff:
2. Reduce the scope of each ¬ to a single term, using the fact that ¬ (¬ p) = p,
deMorgan's laws [which say that ¬ (a ∧ b) = ¬ a V ¬ b and ¬ (a V b) = ¬ a ∧ ¬ b
], and the standard correspondences between quantifiers [¬ ∀x: P(x) = ∃x: ¬
P(x) and ¬ ∃x: P(x) = ∀ x: ¬P(x)]. Performing this transformation on the wff
from step 1 yields
4. Move all quantifiers to the left of the formula without changing their
relative order. This is possible since there is no conflict among variable names.
Performing this operation on the formula of step 2, we get
7. Convert the matrix into a conjunction of disjuncts. In the case or our example, since there are no
and’s, it is only necessary to exploit the associative property of or [ i.e., (a ∧ b) V c = (a V c) ∧ (b ∧ c)] and
simply remove the parentheses, giving
¬ Roman(x) V ¬ know(x, Marcus) V
hate(x, Caesar) V ¬ hate(y, z) V thinkcrazy(x, y)
9. Standardize apart the variables in the set of clauses generated in step 8. By this we
mean rename the variables so that no two clauses make reference to the same
variable. In making this transformation, we rely on the fact that
(∀x: P(x) ∧ Q(x)) = ∀x: P(x) ∧ ∀x: Q(x)
Thus since each clause is a separate conjunct and since all the variables are
universally quantified,
there need be no relationship between the variables of two clauses, even if they
were generated
from the same wff.
Resolution in Propositional Logic
In order to make it clear how resolution works, we first present the resolution procedure for
propositional logic. We then expand it to include predicate logic.
In propositional logic, the procedure for producing a proof by resolution of proposition P
with respect to a set of axioms F is the following.
Algorithm: Propositional Resolution
1 . Convert all the propositions of F to clause form.
2. Negate P and convert the result to clause form. Add it to the set of clauses obtained in step 1.
3. Repeat until either a contradiction is found or no progress can be made:
(a) Select two clauses. Call these the parent clauses.
(b) Resolve them together. The resulting clause, called the resolvent, will be the disjunction of all of
the literals of both of the parent clauses with the following exception: If there are any pairs of literals
L and ¬ L such that one of the parent clauses contains L and the other contains ¬ L, then select one
such pair and eliminate both L and ¬ L from the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has been found. If it is not, then add it to
the set of clauses available to the procedure.
Let's look at a simple example. Suppose we are given the axioms
shown in the first column of Fig. 5.7 and we want to prove R. First we convert
the axioms to clause form, as shown in the second column of the figure.
If [X is a frog]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog]
[Fritz is a frog] Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog]
[Fritz is a frog] Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
[Fritz is a frog]
Goal
[Fritz is colored Y]?
If [X is a frog]
[Fritz is a frog] Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
[Fritz is a frog]
Goal
? [Fritz is colored Y]?
If [X is a frog]
[Fritz is a frog] Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
[Fritz is a frog]
Goal
[Fritz is colored Y]?
If [X is a frog] If [X is a frog]
[Fritz is a frog] Then [X is colored green]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog] If [X is a frog]
[Fritz is a frog] Then [X is colored green]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog] If [X is a frog]
[Fritz is a frog] Then [X is colored green]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
? [Fritz is colored Y]?
If [X is a frog] If [X is a frog]
[Fritz is a frog] Then [X is colored green]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
[Fritz is colored Y]?
If [X is a frog] If [X is a frog]
[Fritz is a frog] Then [X is colored green]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goal
Y = green [Fritz is colored Y]?
If [X is a frog]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goals
[Fritz is colored Y]?
If [X is a frog]
Then [X is colored green]
If [X is a canary]
Then [X is colored yellow]
Goals
[Fritz is colored Y]?
If [X is a frog]
Then [X is colored green]
[X is a frog] If [X is a canary]
Then [X is colored yellow]
Goals
[Fritz is colored Y]?
If [X is a frog]
Then [X is colored green]
[X is a frog] If [X is a canary]
Then [X is colored yellow]
Goals
[Fritz is colored Y]?
[X is a frog]
If [X is a frog]
Then [X is colored green]
[X is a frog] If [X is a canary]
Then [X is colored yellow]
Goals
[Fritz is colored Y]?
[X is a frog]
If [X is a frog]
Then [X is colored green]
Goals
[Fritz is colored Y]?
[X is a frog]
If [X is a frog]
Then [X is colored green]
Goals
[Fritz is colored Y]?
[X is a frog]
[X is a canary]
If [X is a frog]
Then [X is colored green]
Goals
[Fritz is colored Y]?
[X is a frog]
[X is a canary]
If [X is a frog]
Then [X is colored green]
[X is a canary]
If [X is a frog]
Then [X is colored green]
[X is a canary]
If [X is a frog]
Then [X is colored green]
[X is a canary]
If [X is a frog]
Then [X is colored green]
[X croaks and eats flies] [Fritz croaks and eats flies] [X is a frog]
[X is a canary]
If [X is a frog]
Then [X is colored green]
[X croaks and eats flies] [Fritz croaks and eats flies] [X is a frog]
[X is a canary]