0% found this document useful (1 vote)
326 views39 pages

3 Logic - V3

This document discusses the key concepts of logic, including: 1) It defines logic as the study of reasoning and analyzing statements for their truthfulness. Two types of logic covered are propositional logic and predicate logic. 2) Propositional logic uses atomic statements and logical connectives like "and", "or", and "not" to form compound statements. Truth tables are used to determine the truth value of statements for different combinations of atomic statement values. 3) Predicate logic builds on propositional logic by adding predicates and quantifiers to make statements about objects and properties. Formal techniques like resolution and refutation are used to analyze the logical inferences and reasoning in predicate logic statements.

Uploaded by

Ay Sy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
326 views39 pages

3 Logic - V3

This document discusses the key concepts of logic, including: 1) It defines logic as the study of reasoning and analyzing statements for their truthfulness. Two types of logic covered are propositional logic and predicate logic. 2) Propositional logic uses atomic statements and logical connectives like "and", "or", and "not" to form compound statements. Truth tables are used to determine the truth value of statements for different combinations of atomic statement values. 3) Predicate logic builds on propositional logic by adding predicates and quantifiers to make statements about objects and properties. Formal techniques like resolution and refutation are used to analyze the logical inferences and reasoning in predicate logic statements.

Uploaded by

Ay Sy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

CHAPTER 3
LOGIC

WHAT IS LOGIC?_______________________________________ 1
PROPOSITIONAL LOGIC _________________________________ 2
CONNECTIVES _______________________________________ 3
TRUTH TABLES ______________________________________ 5
EQUIVALENCES ______________________________________ 6
AND/OR GRAPH ______________________________________ 8
REASONING ________________________________________ 10
INFERENCE TECHNIQUES _____________________________ 12
PREDICATE CALCULUS ________________________________ 15
REASONING & INFERENCE TECHNIQUES IN PREDICATE
CALCULUS _________________________________________ 18
RESOLUTION REFUTATION____________________________ 19
PRACTICE MAKES PERFECT ____________________________ 23

3:0
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

3 LOGIC

WHAT IS LOGIC?
Logic is one of the basic disciplines of computer science. Logic is primarily concerned with
reasoning about the truth of statements. Logic is used to reason about the truth values of a
sentence. Logic concerned with the truthfulness of a chain of statements. Consider the
following three sentences:

1. All mice have four legs.


Premises
2. Minnie is a mouse.

3. Therefore, Minnie has four legs. Conclusion

Two kind of logic to be discussed in this chapter are propositional logic and predicate logic.

3:1
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

PROPOSITIONAL LOGIC
Proposition is commonly used to refer to a statement. A proposition (or statement) can be
assigned truth values: true (T) or false (F). Propositional logic is the simplest of logic. The
smallest entity to which a value of true or false can be assigned is called an atomic
proposition (or known as atom). Two or more atomic propositions can be combined
together with a connective to produce a compound proposition. For example, the following
are propositions:

1. Siti is a teacher. : atomic proposition


2. Zubaidah is a teacher. : atomic proposition
3. Siti and Zubaidah are a teacher : compound proposition

Each of the propositions has a truth value of ‘true’ or ‘false’. For example, consider the first
sentence. If I happen to know a person named Siti who worked as a teacher and the
proposition is referred to the particular person, then the value of the proposition would be
‘true’. In the situation, where Siti in the first sentence is referring to Datuk Siti Nurhaliza, this
proposition would have a value of ‘false’.

Propositional logic has a formal language which allows us to formally represent propositions
and to construct complex sentences that are composed from two or more atomic
propositions. There are two aspects of language: syntax and semantics. Syntax is
concerned with the how the symbols can be combined to represent sentences and
semantics is concerned with the meaning.

The formal language of propositional logic defines a set of symbols for representing
propositions and a set of symbols for representing the logical connectives (or also referred to
as logical operators).

English sentences that we use in daily life can be formalized using propositional logic. The
process involves identifying the smallest parts of the sentence that can be assigned truth
values and denote these parts using propositional symbols. Link the small parts using the
connectives. For example, given the following sentences and their symbols:

Muzaffar is an astronaut. p
Faiz is an astronaut. q

From the example above, the sentence below can be structured by using the connective and
(which symbol is ).

Muzaffar is an astronaut and Faiz is an astronaut. pq

Consider another example:

3:2
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Amin’s keys are in the car or hung up in the office.

The smallest parts identified in this sentence are:


• Amin’s keys are in the car.
• Amin’s keys are hung up in the office.

Denote these parts as propositional symbols:


• Amin’s keys are in the car. p
• Amin’s keys are hung up in the office. q

Link these symbols using connective or to produce an expression:


pq

CONNECTIVES

The connectives (or also known as logical operator) are defined using truth tables.
Connectives can be unary or binary connectives.

Unary connectives: the connective with only one argument. The only unary connective is not.

Binary connectives: the connective which take two arguments. A binary connective connects
two propositions together.

Below are some connectives used in propositional logic:

Connective Symbol
and , ∩, 
or , 
not ¬,~
implies →, 
equivalent ≡,↔

Not connective (negation)

Not connective has the effect of inverting the truth value of the argument. The
negation of true is false and vice versa.

A sentence of a form ¬A i s true, if A is false and vice versa. (As shown in truth table
3).

And connective (conjunction)

The compound proposition which consist of two arguments and connected with an
and, will only be true if both arguments are true.

A sentence of a form A  B will only be true if A and B is both true. (As shown in truth
table 1).

Example: ‘I have a million ringgit and a house in Kuala Lumpur’. This sentence is
only true if I have a million ringgit and the house. If I have a million ringgit, but don’t
have the house, this sentence is false.

3:3
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Or connective (disjunction)

The compound proposition which consist of two arguments and connected with an or,
will be true if one or both arguments are true.

A sentence of a form A  B will be true if either A or B is true. (As shown in truth


table 2).

Example: ‘I want to buy the red dress or the blue blouse’. This sentence can be
interpreted as ‘I want to buy the red dress or the blue blouse, or both the red dress
and the blue blouse’.

Implies connective

In an expression of the form p → q, p and q are known as follows.

p antecedent, evidence
q consequent, hypothesis

The compound proposition which consist of two arguments and connected with an
implies, will be true if one or both arguments are true.

In a sentence of a form A → B, A is known as the antecedent and B is the


consequent. This sentence is only false when the antecedent is true but the
consequent is false. (As shown in truth table 4).

Example: ‘If I am hungry, then I will eat’. Imagine the situation where you are visiting
a friend, and she ask you whether you want to taste her new recipe. Assuming you
make the given statement and you still do not eat when you are hungry. Then you
have lied to your friend about your statement.

Consider another example: ‘If the battery is dead (A), then the car can’t start (B)’. We
could translate the statement into A → B. There are four possible condition of this
statement:
A B
Battery is dead (T) → car can’t start (T) T
Battery is dead (T) → car can start (F) F
Battery not dead (F) → the car can’t start (T) T
Battery not dead (F) → car can start (F) T

3:4
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

TRUTH TABLES

The truth table for a connective defines what is the truth value should be assigned to a
compound proposition, given each combination of truth values for the component
propositions. For example, in the sentence p  q. Both p and q can have values of T or F.
The truth tables for all four connectives are shown as below.

Any expression can be categorized as tautology, contradiction and contingency. Each of


which as explained below:

Tautology: is a condition when all values are TRUE.


Contradiction: is a condition when all values are FALSE.
Contingency: is a condition when some values are TRUE and some others are FALSE.

Truth Table 1. And connective (conjunction) Truth Table 2. Or connective(disjunction)


p q pq p q pq
T T T T T T
T F F T F T
F T F F T T
F F F F F F

Truth Table 3. Not connective Truth Table 4. Implication connective


p ¬p p q p→q
T F T T T
F T T F F
F T T
F F T

Truth Table 5. Equivalent connective


p q p≡q
T T T
T F F
F T F
F F T

Tips Box. Truth table

Procedure to find the truth table for an expression can be described as several basic
steps:

1. Count the number of atomic propositions, n.


2. Calculate number of rows needed, 2n.
3. Fill in the columns with T and F.
4. Form the other columns by breaking the expression into simple component parts.

3:5
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Example (p  q)  (p  r)

Solution 1. Number of atomic propositions is 3: p, q and r.


2. Number of rows needed: 2n = 23 = 8
3. Fill in the columns:
1 2 3
p q r
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F

4. Form the other columns by breaking the expression into simple component
parts.
1 2 3 4 5 4 5
p q r pq pr (p  q)  (p  r)
T T T T T T
T T F T T T
T F T T T T
T F F T T T
F T T T T T
F T F T F F
F F T F T F
F F F F F F

EQUIVALENCES
If two expressions have the same truth table, they are said to be equivalent. The symbol ≡
is used to denote equivalence. For example:

(p  q)  (p  r) ≡ p  (q  r)

This can be checked by the following truth table, showing that the resultant columns (in grey)
are the same.
1 2 3 4 5 4 5 6 7
p q r pq pr (p  q)  (p  r) (q  r) p  (q  r)
T T T T T T T T
T T F T T T F T
T F T T T T F T
T F F T T T F T
F T T T T T T T
F T F T F F F F
F F T F T F F F
F F F F F F F F

3:6
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Equivalence can also be proven by using several laws. This is shown in the following table.

Idempotent A→B AB

¬(¬A) ≡ A
De Morgan’s ¬(A  B) ≡ ¬A  ¬B
¬(A  B) ≡ ¬A  ¬B

(A  B)  C ≡ A  (B  C)
Association
(A  B)  C ≡ A  (B  C)

(A  B)  C ≡ (A  C)  (B  C)
Distributive
(A  B)  C ≡ (A  C)  (B  C)

Contradiction A  ¬A ≡ F

Tautology A  ¬A ≡ T

AB≡ BA
Commutative
AB≡ BA

A  (A  B) ≡ A
Absorption
A  (A  B) ≡ A

Example Prove that the following expressions are equivalent.


p → ( q →r ) ≡ ( p  q ) → r

Solution p → ( q →r )
≡ ¬p  ( q →r ) Idempotent Law
≡ ¬p  (¬q  r ) Idempotent Law
≡ (¬p  ¬q )  r Association Law
≡ ¬(p  q )  r De Morgan’s Law
≡(pq)→r Idempotent Law

Tips Box . Order of precedence

The order of precedence is as follows:


1. brackets
2. ¬
3. 
4. 
5. →

3:7
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

AND/OR GRAPH
Logical operators AND and OR could be represented in a graph called AND/OR graph. This
graph connects nodes by sets of arcs. This is shown in the figure below:

AND CONNECTOR C
A B→C

A B
C C

OR CONNECTOR C
A B→C

A B
C C

If the truth value of the fact is known, a box is drawn to represent its value.

Example Given the following rules and fact:

A B→C
A
B

Solution C

A B

3:8
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

EXERCISE & SOLUTION

Find the complete set of truth values for all possible truth assignments to p and q in the
following expressions.

Ex1 (p → q)  (q → p)

Solution 1 2 3 4 34
p q p→q q→p (p → q)  (q → p)
T T T T T
T F F T F
F T T F F
F F T T T

Ex2 ((p → q)  (q → p)) → (p → q)

Solution 1 2 3 4 5: 3  4 5→3
p→q q→p (p → q)  (q → p) (p → q)  (q → p)
p q → (p → q)
T T T T T T
T F F T F F
F T T F F F
F F T T T T

Given the following rule base, draw the AND/OR graph for the following knowledge.

Ex3 A
B
C
A B→C
A C→E
B D→F
F→G
A  E→ H

Solution
H
G

E
F

A B D

3:9
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

REASONING

Reasoning is a process of working with knowledge, facts and


problem-solving strategies to draw conclusion. Reasoning is similar to
the process done by human when they are trying to solve problems.
In making decision, we always have to infer to several rules that we
have stated earlier.

There are several strategies of reasoning as discussed as follows:

Deductive reasoning

This type of reasoning involves process used by humans to deduce new information
from logically related known information. Human usually uses problem facts (axioms)
and related knowledge which are in the form of rules in problem solving. These rules
and facts should have been proven or accepted before they can be compared to the
axioms in order to conclude new axioms.

Example:
Premise : I will get wet if I am standing in the rain (A → B)
Premise : I am standing in the rain (A)
Conclusion : I will get wet (B)

This type of reasoning is logically appealing and become one of the most common
problem-solving techniques used by humans. The modus ponen inference technique
is the basic form of deductive reasoning

Inductive reasoning

Inductive reasoning derives a general conclusion about the environment as a whole,


from specific facts, or a set of observed cases. This type of reasoning is always used
when there is limited number of cases (or observations) to use, and conclusions are
made by assuming the cases can be applied to all related problem.

Humans use inductive reasoning to make a general conclusion by generalizing what


they have observed.

Example:
Premise : Monkeys in the National Zoo eat bananas
Premise : Monkeys in the Taiping Zoo eats bananas
Conclusion : All monkeys eat bananas

Abductive reasoning

This is another type of reasoning where conclusion is made based on available


information. However, the conclusion might be right or might be wrong.

Example:
Premis : If a person has hypertension, he has heart attack
Premis : My grandfather has heart attack
Conclusion : My grandfather has hypertension

3:10
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

From the example given above, conclusion made is might be right or wrong even
though those two premises are true. The heart attack might not be caused by the
hypertension. It might be triggered by any other reason.

Analogical reasoning

Analogical reasoning is a reasoning type where human takes note of the fact that two
or more things are similar in some respects and concludes that they are probably
also similar in some further respect. In analogical reasoning, an analogy for a given
thing or situation is found, where the analogy is like the given thing in some way.
Other attributes of the analogical situation are then taken to also represent other
attributes of the given thing

Example:
Premise : MyVi is one of Perodua’s car.
Premise : MyVi is sold at a reasonable price.
Premise : MyVi is a very good car.
Premise : Viva is one of Perodua’s car.
Conclusion : Viva is a very good car and sold at a reasonable price.

In the example given above, an analogy is built about Perodua MyVi, and using the
same analogy the conclusion about Perodua Viva is achieved.

Common-sense reasoning

Through experience, humans learn to solve problems efficiently. It relies more on


good judgment rather than precise logic. This kind of knowledge is also referred to as
a heuristic or rule-of-thumb, which helps making decision much faster.

Example:
An experienced chess player plays chess based on experiences and
observations. While a novice player plays chess without any knowledge. This
kind of reasoning involves obtaining facts by observation, experience and use
them in solving problem.

Non-monotonic reasoning

Several terminologies:
Monotonic: something static and during execution the fact remain constant.
Non-monotonic: changing information during execution (human can adapt
with changes).

Non- monotonic reasoning deals with dynamic situations, where particular facts can
change as new information during execution. There are so many non-monotonic
factors that might affect the conclusion, for example, the weather, stock process,
foreign exchange, etc.

3:11
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

INFERENCE TECHNIQUES

Inference is reasoning mechanisms that are used to relate between facts and rules, to derive
new conclusions or facts. Inference used to determine when and how to retrieve, match
and execute what and which knowledge.

There are four inference techniques to be discussed in this chapter, which are as follows:

Modus Ponens

Modus ponens is an inference technique where given a rule, and the condition is
true, we can infer the conclusion is also true. Modus ponens can be summarized in
the following form:

X→Y
X
Conclude: Y

A simple example of the use of modus ponens in the propositional calculus, assume
the following observations:

If it is raining, then ground will be wet.


It is raining.
The ground will be wet.

Through an application of modus ponens, the fact that the ground will be wet, may be
added to the set of true expressions. In other words, modus ponens can be
formularized as ((X→ Y)  X ) → Y. The formula means when X implies Y is true and
we know that X is true, and then we can conclude Y is true.

Modus Tollens

Modus Tollens is quite similar to modus ponens. Under the inference rule modus
tollens, if given a rule known to be true, and the consequence is known to be false,
we can infer that the condition is also false. A summary of modus tollens can be seen
in following formula:

X→Y
¬Y
Conclude: ¬X

The example below illustrates the usage of modus tollens:

If I am tired, I will sleep early.


I will not sleep early.
I am not tired.

Compared to modus ponen and hypothetical syllogism, modus tollens is a less useful
technique because its emphasis is on the negation of facts.

3:12
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Hypothetical Syllogism

Hypothetical syllogism is one of the proof rules in classical logic that may or may not
be available in a non-classical logic. The hypothetical syllogism is a valid argument of
the following form:

P → Q.
Q → R.
P → R.

When the conclusion of one rule is the condition of a second rule, then you can
establish a third rule whose antecedent is that of the first rule and whose consequent
belong to the second rule.

Example:
If I do not wake up, then I cannot go to work.
If I cannot go to work, then I will not get paid.
Therefore, if I do not wake up, then I will not get paid.

Resolution Refutation

Another technique to come with conclusion, based on the statements given is


refutation. There are several steps involved in refutation.

1. Convert all propositions of F to clause form.


Simplify all the rules by eliminating the implies operator → by substituting rules
with their standard equivalence rules. These simplified rules are said to be in the
clause form.

2. Negate the goal and convert result to clause form. Add the result to the clauses
obtained in step 1.

3. Repeat until either a contradiction occurs or no progress can be made.


a) Select two clauses call these parent clauses
b) Resolve the clauses using disjunction if any pairs of literal L or ~L occur in
the two parent clauses pick one and eliminate it from the result
c) If the result is empty then the contradiction has been found otherwise add
the result to the set of clauses

3:13
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Example Given the following rules:


p→q
p

Prove q is the conclusion made.

Solution 1. Convert all propositions of F to clause form.


p→q ≡ pq (Use idempotent law)
p (Already in clause form)

2. Negate the goal and convert result to clause form.


q (Already in clause form)

All clauses: 1)  p  q
2) p
3)  q

3.  q pq

p p

4. The goal is proven true.

EXERCISE & SOLUTION

Ex1 Construct the proposition for the following sentences.


If you are fussy and have bad temper, you do not have many friends.

Solution 1. Identify the atoms.


P : You are fussy.
Q : You have a bad temper.
R : You have many friends.

2. Link the atoms with connectives.


(P  Q ) →  R

3:14
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

PREDICATE CALCULUS

In propositional calculus, each atomic symbol (P,Q, etc) denotes a proposition of some
complexity. There is no way to access the components of an individual assertion. This is
because the propositional logic is the simplest form of logic. Propositional logic is limited in
expressiveness and it is not good in representing situations.

For example, instead of representing the whole sentence ‘it rained on Tuesday’ with a single
symbol, we can create a predicate weather that describes the relationship between a date
and the weather: weather(tuesday,rain).

Another fall back of using propositional logic is some symbolized argument might not be
valid. For further understanding of this deficiency, the following example illustrates the
problem.

Every dog has a master.


Sadie is a dog.
Therefore, Sadie has a master.

Using propositional calculus, the sentences above might be represented as:

Every dog has a master. P


Sadie is a dog. Q
Therefore, Sadie has a master. R

The symbolized argument is not valid and yet we can see that the original premises must
surely imply the conclusion Sadie has a master.

First Order Predicate Calculus (FOPC) is a more expressive type of logic, builds upon
propositional logic. Most of what presented previously in this chapter carries over to FOPC.

Several symbols are used in FOPC. Several terminologies to understand before constructing
the FOPC are as follows:

Predicate
The word used in FOPC to describe the symbols used when we make claims
about the object or relations between objects. Predicates are symbol expression
which having the first character lowercase.

Argument
The symbol representing the object enclosed within the parenthesis. An
argument can be a constant or variable symbol.

Arity
The number of arguments enclosed within the parenthesis. A predicate which has
arity = 1, is called unary predicates. While binary predicates has arity of 2.

Constant
The set of names used to refer to particular objects. These symbol expressions
have first character lowercase.

3:15
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Variable
The set of names used to any object. These symbol expressions begin with an
uppercase character.
Quantifier
A variable quantifier used to constrain the meaning of a sentence containing a
variable. There are two types of quantifiers: universal quantifier () and
existential quantifier ().

A valid symbol to be used for predicates, and arguments must only consists of alphabets
(a,b,c,… and A,B,C,…), digits (0, 1, … , 9) and underscore (_). Any other characters are not
allowed in representing the symbols.

The syntax of FOPC can be described as follows:

girl (linda) arity = 1

Linda is a girl.

predicate argument(constant)

father (onn, linda) arity = 2

Onn is Linda’s father.

predicate argument(constant)

X [student(X) → likes (linda, X)]


Some student likes Linda.

existential quantifier predicate argument(constant) argument(variable)

X [student(X) → likes (linda, X)]


All students like Linda.

universal quantifier predicate argument(constant) argument(variable)

Variable VS Constant

Consider the sentence below:

All children like Linda.

In this sentence, there are several objects to be considered. All children describe every child
that exists, while Linda is only one particular person named Linda. Therefore, we need a
variable to describe any children, and a constant to describe Linda.

3:16
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Suppose that we are talking about children in a kindergarten, which are named in the
following set:

{Alia, Anita, Daniel, Amir}

The previous set defines the domain of objects within the world, which we are concerned. If
All children like Linda, it can also be represented as:

likes(alia,linda)  likes(anita,linda)  likes(daniel,linda)  likes(amir,linda)


Concisely, it can be represented as:

X child(X) → likes (X, linda)

The symbol quantifier helps in defining which object in the domain involves in the sentence.
The symbol  is called universal quantifier and defines everything or all. While symbol  is
called existential quantifier defines at least one or some.

EXERCISE & SOLUTION

Express the following in FOPC:

Ex1 Tompok is not a person.


Solution ¬person(tompok)

Ex2 Halim sits opposite Liza.


Solution sits_opposite(halim,liza)

Ex3 If Tompok is a dog, and Abu owns Tompok, then Abu is Tompok’s master.
Solution dog(tompok)  owns(abu,tompok) → master(abu, tompok)

Ex4 Every boy loves football.


Solution X boy(X) → loves (X,football)

Ex5 All members either sing or dance


Solution X member(X) → sing(X)  dance(X)

Ex6 Everybody loves someone.


Solution X Y[person(X)  person(Y) → loves(X,Y)]

Ex7 Everyone loves chocolate


Solution X person(X) → loves(X,chocolate)

3:17
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

REASONING & INFERENCE TECHNIQUES IN PREDICATE


CALCULUS

As discussed in propositional logic, there are several inference techniques could be used.
The same reasoning strategies and inference techniques may be applied with predicate
logic. However, the focus of the following chapter is only on resolution refutation in predicate
calculus.

Unification

Unification means a process that computes the appropriate substitution. The objective of
unification is to find a substitution that will allow two sentences to look the same. Once we
make two sentences look the same, it is possible to apply resolution.

In propositional logic, substitution is easier to be done. Propositions which are written with
the same symbol are considered as substitutes. However, the process is much complicated
for predicates because of the existence of variables and constants.

The basic idea of unification is variables can be replaced by:


• other variables
• constants
• function expressions

The high-level algorithm below helps to understand unification clearly.

3:18
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

EXERCISE & SOLUTION

Ex1 Unify p(a,X) and p(a,b)


Solution b/X

Ex2 Unify p(a,X) and p(Y,b)


Solution a/Y, b/X

Ex3 Unify p(a,X) and p(Y, f(Y))


Solution a/Y, f(a)/X

Ex4 Unify p(a,X) and p(X,b)


Solution Failure
If a/X, X could not be substituted with b because a ≠ b.

Ex5 Unify p(a,X) and p(Y,b)


Solution a/Y, b/X

Ex6 Unify p(a,b) and p(X,X)


Solution Failure
If a/X, X could not be substituted with b because a ≠ b.

RESOLUTION REFUTATION
The only technique to be discussed for predicate calculus is resolution refutation. The other
inference techniques in propositional calculus can simply be applied with predicates as well.
However, some differences appear for predicate calculus. There are several steps involved
in refutation.

1. Convert all predicates of F to clause form.


There are 9 sequential steps to be followed for this part:

Step 1: Eliminate the logical connectives →and ↔


a ↔ b ≡ (a → b)  (b → a)
a → b ≡ ¬a  b

Step 2: Reduce the scope of negation


¬ (¬a) ≡ a
¬ (a  b) ≡ ¬a  ¬b
¬ (a  b) ≡ ¬a  ¬b
¬ (X) a(X) ≡ (X) ¬a(X)
¬ (X) b(X) ≡ (X) ¬b(X)

Step 3: Standardize by renaming all variables so that variables bound by different


quantifiers have unique names.
(X) a(X)  (X) b(X) ≡ (X) a(X)  (Y) b(Y)

Step 4: Move all quantifiers to the left to obtain a prenex normal form.
(X) a(X)  (Y) b(Y) ≡ (X)(Y) a(X)  b(Y)

Step 5: Eliminate existential quantifiers by using skolemization.

3:19
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Skolem constant
• (X)(dog(X)) may be replaced by dog(fido) where the name fido is
picked from the domain of definition of X to represent that individual X.

Skolem function
• If the predicate has more than one argument and the existentially
quantified variable is within the scope of universally quantified
variables, the existential variable must be a function of those other
variables.
• Example:
(X)(Y) (mother(X,Y))
≡ (X)mother(X,m(X))

(X)(Y)(Z)(W)(foo (X,Y,Z,W))
≡ (X)(Y)(W)(foo(X,Y,f(X,Y),w))

Step 6: Drop all universal quantifiers

Step 7: Convert the expression to the conjunction of disjuncts form


(a  b)  (c  d)
≡ (a  (c  d))  (b  (c  d))
≡ (a  c)  (a  d)  (b  c)  (b  d)
Step 8: Call each conjunct a separate clause
(a  c)  (a  d)  (b  c)  (b  d)
(a  c)
(a  d)
(b  c)
(b  d)

Step 9: Standardize the variables apart again.


Variables are renamed so that no variable symbol appears in more than
one clause.
Clause 1: mother(X)  female(X)
Clause 2: father(X)  male(X)

Clause 1: mother(X)  female(X)
Clause 2: father(Y)  male(Y)

2. Negate the goal and convert result to clause form. Add the result to the clauses
obtained in step 1.

3. Repeat until either a contradiction occurs or no progress can be made.


a) Select two clauses call these parent clauses
b) Resolve the clauses using disjunction if any pairs of literal L or ~L occur in the
two parent clauses pick one and eliminate it from the result
c) If the result is empty then the contradiction has been found otherwise add the
result to the set of clauses

3:20
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

Example Given the following rules. Proof that John is happy.


1. Anyone passing his history exams and winning the lottery is happy
2. Anyone who studies or is lucky can pass all his exams.
3. John did not study but he is lucky
4. Anyone who is lucky wins the lottery.

Solution 1. Convert all predicates of F to clause form.

1 Anyone passing his history exams and winning the lottery is happy
X (pass(X,history)  win(X,lottery) → happy(X))

Step1: X ¬(pass(X,history)  win(X,lottery))  happy(X)


Step2: X ¬pass(X,history)  ¬win(X,lottery)  happy(X)
Step6: ¬pass(X,history)  ¬win(X,lottery)  happy(X)

2 Anyone who studies or is lucky can pass all his exams.


X Y(study(X)  lucky(X) → pass(X,Y))

Step1: X Y¬(study(X)  lucky(X))  pass(X,Y)


Step2: X Y ( ¬study(X)  ¬lucky(X))  pass(X,Y)
Step6: ( ¬study(X)  ¬lucky(X))  pass(X,Y)
Step7: (¬study(X)  pass(X,Y))  (¬lucky(X)  pass(X,Y))
Step8: (¬study(X)  pass(X,Y))
(¬lucky(X)  pass(X,Y))
Step9: (¬study(Z)  pass(Z,Y))
(¬lucky(A)  pass(A,B))

3 John did not study but he is lucky


¬study(john)  lucky(john)

Step7: ¬study(john)
lucky(john)

4 Anyone who is lucky wins the lottery.


X (lucky(X) → win(X,lottery))

Step1: X ¬lucky(X)  win(X,lottery)


Step6: ¬lucky(X)  win(X,lottery)
Step9: ¬lucky(C)  win(C,lottery)

2. Negate the goal and convert result to clause form.

Goal: John is happy


Negate: ¬happy(john) (Already in clause form)

All clauses: 1) ¬pass(X,history)  ¬win(X,lottery)  happy(X)


2) ¬study(Z)  pass(Z,Y)
3) ¬lucky(A)  pass(A,B)
4) ¬study(john)
5) lucky(john)

3:21
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

6) ¬lucky(C)  win(C,lottery)
7) ¬happy(john)

3. Resolve using all the clauses.

¬happy(john) ¬pass(X,history)  ¬win(X,lottery)  happy(X)

{X/john}

¬pass(john,history)  ¬win(john,lottery) ¬lucky(C)  win(C,lottery)

{C/john}

¬lucky(A)  pass(A,B) ¬pass(john,history)  ¬lucky(john)

{A/john, B/history}

¬lucky(john) lucky(john)

➔ The goal is proven true.

3:22
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

PRACTICE MAKES PERFECT

1. Consider the following propositions:


p: Logic is easy
q: There is a logic question
r: I pass the exam

Construct the propositional logic for the following sentences.

a) If logic is easy then I pass the exam.

b) If I pass the exam then logic is easy.

c) I fail the exam if logic is difficult.

d) If there is no logic question, then I pass the exam.

e) Logic is difficult. I pass the exam if there is no logic question.

2. Proof the following using truth table and/or statement algebra.

a. ( p q) → r ≡ ( p ¬ r) → ¬ q

3:23
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

b. ((P  Q) → R) ≡ ¬((P  Q)  ¬R)

3. Given P and Q are true, and R and S are false. Find the values of the following
expressions:

a) ( ⌐(P^Q) v ⌐R) v ((Q → ⌐P) → (R v ⌐S))

3:24
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

b) (P → R) ^ (⌐Q → S)

4. Verify that the following logical expressions are tautology by computing its truth table.

a) (P→ ¬(¬P))  ( ¬(¬P) → P)

3:25
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

b) (P  (P→Q))→Q

5. Given the following propositions:

P : You are fussy.


Q : You have a bad temper.
R : You have many friends.

Construct the proposition for the following sentences and create the truth table.

If you are fussy and have bad temper, you do not have many friends.

3:26
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

6. Let pp, qq, and rr be the following propositions:

pp: You get an A on the final exam


qq: You do every exercise in the book
rr: You get an A in this class.

Write the following rules using pp, qq, and rr and logical connectives, and draw the
AND/OR graph for those rules below.

a) You get an A in this class, but you do not do every exercise in the book.

b) To get an A in this class, it is necessary for you to get an A on the final.

c) Getting an A on the final and doing every exercise in the book is sufficient for getting
an A in this class.

AND/OR graph:

7. Let the following rules apply:

R1: If a then b
R2: If c then d
R3: If e then f
R4: If g then a
R5: If h then c
R6: If d then i

Draw an AND/OR graph to represent the rules given.

3:27
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

8. Consider the following rules below, and then answer the following questions.
R1: If it's a nice day and it's summer, then I'll go to the golf course
R2: If it's a nice day and it's winter, then I'll go to the ski resort
R3: If it's not a nice day and it's summer, then I'll go to work
R4: If it's not a nice day and it's winter, then I'll go to class
R5: If I go to the golf course, then I'll play golf
R6: If I go to the ski resort, then I'll go skiing
R7: If I go skiing or play golf, then I'll have lots of fun
R8: If I go to work, then I'll be making money
R9: If I go to class, then I'll learn something useful

Construct an AND/OR graph based on the rules above.

9. Use the following premises to prove the goals using resolution refutation.

a) PQ
P→R
Q→R
Goal: R

3:28
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

b) (P → Q) → Q
(P → P) → R
(R → S) → ¬(S → Q)
Goal: R

c) P→Q
¬P → ¬R
Goal: ¬Q → ¬R

3:29
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

d) ¬(P  ¬Q)  ¬(¬S  ¬T)


¬(T  Q)
U → (¬T →(¬S  P))
Goal: ¬U

e) (b  c) → a
b
(d  e) → c
ef
d  ¬f
Goal: a

3:30
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

10. Translate the following predicates into English sentences:

a) X Y father (X, Y) → male(X)  parent(X, Y)

b) X Z Y grandfather(X, Z) → father(X, Y)  father(Y, Z)

c) X Y son(X, Y) → male(X)  parent(Y, X)

d) X Y brother(X, Y) → male(X)  sibling(X, Y)

11. Represent the knowledge given below using propositional logic and prove the exciting
life using resolution refutation.

All people who are not poor and are smart are happy. Those people who read are not
stupid. John can read and is wealthy. Happy people have exciting lives.

3:31
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

12. Translate the following sentences to predicate calculus expression.

1) Apples are food.

2) Chicken is food.

3) Bill likes ice-cream.

4) Bill is tall.

5) Billy studies A12.

6) Kristen Dunst is an actress

7) Popeye loves spinach.

8) Dave never eats boiled eggs

9) Bill takes edam cheese

10) The umbrella is red in colour


11) Stalin was a dictator and not an Ancient
Greek
12) Bill eats peanuts is still alive.
13) Rudolph is a rain deer, Rudolph has a
red nose.

3:32
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

14) Every child loves Santa.

15) Every man likes a tasty apple

16) All animals eat custard.

17) All humans are mortal.

18) All Welsh people are British.

19) All rich people pay taxes.

20) Everybody loves somebody.

21) John likes all kind of food.

22) Sue eats anything Bill eats.

23) Anything anyone eats and isn’t killed by is food.

24) Every apple is either green or yellow

25) No person likes a smart vegetarian

26) All horses have four legs as well as two eyes

27) Everyone who loves Santa loves reindeer.

28) Rudolph is a rain deer, Rudolph has a red nose.

29) Anything which has red nose is weird or is a clown.

3:33
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

30) No rain deer is a clown.

31) Scrooge does not love anything that is weird.


32) Only candidates who had paid their fees will be
allowed to take the examination
33) Every English support either Liverpool or Manchester
United
34) There does not exist a green apple which is not tasty

35) Not all the courses in AI department are hard

36) Any female who is very patient could be a good friend.


37) Anyone who is good friend and has a friend should
always be with his or her friend.
38) If today is Saturday and the weather is sunny,
therefore Mike is at the cafeteria.
39) If today is Saturday, and it is raining, therefore Mike is
at library.
40) Two people live in the same house if they have the
same address.
41) Two people are siblings if they have the same parents.
42) ***Jack owns a dog. Every dog owner is an animal
lover.
No animal lover kills an animal.
Either Jack or Curiosity killed the cat, which is named
Claude.

3:34
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

13. Attempt to unify the following pair of expressions. Either show the unifiers or explain
why they will not unify.

a) parent(X,Y) and parent(ali,Z)

b) similar(X,X) and similar(a,b)

c) queen(A) and ⌐queen(elizabeth)

d) ancestor(X,father(X)) and ancestor(ali,ahmad)

e) father(a,X) and father(b,c)

f) parent(father(A),B) and parent(father(x),y)

g) parent(father(X),B) and parent(w,y)

14. Convert the following sentences into a clausal form:

a) ( X ((Y loves(X,Y) v loves(Y.X)) → happy (X)))

b) ( X happy(X) → (Y loves (X,Y)))

c) (( X black(X))  ¬ (X white(X))) v ( X white (X))

3:35
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

15. Use resolution refutation to prove the statement given.

a. All dogs are animal. Fido is a dog. All animals will die. Prove that Fido will die.

Solution:
Step 1: Transform into Predicate Statement (FOLC)

Statement 1: All dogs are animal


Predicate 1:

Statement 2: Fido is a dog


Predicate 2:

Statement 3: All animals will die


Predicate 3:

Step 2: Transform into clausal form

Clausal 1:

Clausal 2:

Clausal 3:

Step3: Skolemization (if any)

Step 4: Negate the goal

Goal statement: Fido will die


Predicate:

Negation:

Step 5: Resolution graph

3:36
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

b. All dogs like bones. Dogs eat everything they like. Pasta is a dog. Prove that Pasta
eat bone.

Solution:
Step 1: Transform into Predicate Statement (FOLC)

Step 2: Transform into clausal form

Step3: Skolemization (if any)

Step 4: Negate the goal

Goal statement:
Predicate:

Negation:

Step 5: Resolution graph

3:37
MODULE – LECTURE NOTES ISP542/ITS462 LOGIC

c. Sam is pink. Oscar is gray and likes Clyde. Oscar is either pink or gray. Oscar likes
Sam.
Prove that: [gray(X)  pink(Y)  likes(X,Y)]

d. All people who are not poor and are smart are happy. Those people who read are
not stupid. John can read and is wealthy. Happy people have exciting lives. Prove
that John has an exciting life.

e. No animal lover kills any animal. Jack owns a cat. Every cat owner is an animal
lover. Either Jack or Curiosity killed Tuna. Tuna is a cat. All cats are an animal.
Prove that Jack did not kill Tuna.

f. John likes all kinds of food. Anything anyone eats and isn’t killed by is food. Bill
eats peanuts and he is still alive. Sue eats everything Bill eats. Prove that John like
peanuts.

g. Every child loves Santa. Everyone who loves Santa loves any reindeer. Rudolph is
a reindeer and Rudolph has a red nose. Anything which has a red nose is weird or
is a clown. No reindeer is a clown. Scrooge does not love anything which is weird.
Prove that Scrooge is not a child.

h. Tony, Mike, and John are members of the Alpine Club. Every member of the Alpine
Club is either a skier or a mountain climber. No mountain climber likes rain. All
skiers like snow. Mike dislikes whatever Tony likes and likes whatever Tony
dislikes. Tony likes rain and snow. Prove that Mike a mountain climber.

i. Anyone who rides Harley is a rough character. Every biker ride either a Harley or a
BMW. Anyone who rides BMW is a yuppie. Every yuppie is a lawyer. Any nice girl
does not date anyone who is a rough character. Mary is a nice girl, and John is a
biker. If John is not a lawyer, proof that Mary does not date John.

j. Anyone whom Mary loves is a football star. Anyone who does not pass does not
play. Michael is a student. Anyone who does not study does not pass. Anyone who
does not play is not a football star. Michael does not study. Prove that Mary does
not love Michael.

k. Every coyote chases some roadrunner. Every roadrunner who says “beep-beep” is
smart. No coyote catches any smart roadrunner. Any coyote who chases some
roadrunner but does not catch it is frustrated. All roadrunners are smart. Wendy is
a roadrunner. Prove that all coyotes are frustrated.

3:38

You might also like