IntSys Lec 04 Predicate Calculus DR - Mina
IntSys Lec 04 Predicate Calculus DR - Mina
20
21
Dr. Mina Younan
Lecture Outline
// this lecture collected and edited from Prof. Moheb Girgis Lectures in AI
Part One (cont.):
• The Propositional Calculus
• Rules of forming legal propositional calculus sentences
• The semantics of the propositional calculus
• Satisfiability and Validity Concepts
• The predicate calculus
o The syntax of the predicate calculus
o Predicate calculus sentences
o Verify Function
o Relationships between quantifiers
o Representing English sentences in predicate calculus
20
21
Dr. Mina Younan
Intelligent Systems 2
The Propositional Calculus
20
21
Dr. Mina Younan
Intelligent Systems 3
Rules of forming legal propositional calculus
sentences
1. Every propositional symbol and truth symbol is a sentence.
e.g. true, P, Q, and R are sentences.
2. The negation of a sentence is a sentence.
e.g. רP and רfalse are sentences.
3. The conjunction, i.e. and, of two sentences is a sentence.
e.g. P Q is a sentence.
4. The disjunction, i.e. or, of two sentences is a sentence.
e.g. P Q is a sentence.
5. The implication of one sentence from another is a sentence.
e.g. P Q is a sentence.
6. The equivalence of two sentences is a sentence.
e.g. P Q R is a sentence.
Legal sentences are also called well-formed formulas or WFFs.
20
21
Dr. Mina Younan
Intelligent Systems 4
Rules of forming legal propositional calculus
sentences
• In P Q, P and Q are called conjuncts.
• In P Q, P and Q are called disjuncts.
• In P Q, P is the premise and Q is the conclusion.
• It means P implies Q. If the implication is true when the
premise is true, the conclusion must also be true.
20
21
Dr. Mina Younan
Intelligent Systems 5
The semantics of the propositional calculus
• A propositional symbol corresponds to a statement about the world.
For example, P may denote the statement "it is raining".
• A proposition may be either true or false, given some state of the world.
• The truth value assignment to propositional sentences is called an
interpretation, an assertion about their truth in some possible world.
• Formally, an interpretation is a mapping from the propositional symbols
into the set {T, F}.
• Each possible mapping of truth value onto propositions corresponds to a
possible world of interpretation.
• Note that, the symbols true and false are part of the set of well-formed
sentences of the propositional calculus; i.e. they are distinct from the truth
value, T/F, assigned to a sentence.
20
21
Dr. Mina Younan
Intelligent Systems 6
The semantics of propositional calculus
The semantics of propositional calculus is defined as follows:
1. An interpretation of a set of propositions is the assignment of a truth value,
either T or F, to each propositional symbol.
For example, if P denotes the proposition "it is raining" and Q denotes
"I am at work", then the set of propositions {P, Q} has different functional
mapping into the truth values {T, F}. These mappings correspond to 4
different interpretations.
2. The interpretation or truth value assignment for sentences is determined as
follows:
20
21
Dr. Mina Younan
Intelligent Systems 7
The semantics of propositional calculus
2. The interpretation or truth value assignment for sentences is determined as
follows:
20
21
Dr. Mina Younan
Intelligent Systems 8
The semantics of propositional calculus
The truth assignments of compound propositions are often described by truth
tables.
Example: The truth table for P Q: PQ Q P
T T T
The truth tables for , , ר, and can be F F T
defined in a similar fashion.
The equivalence of two expressions may be T T F
demonstrated using truth tables. T F F
20
21
Dr. Mina Younan
Intelligent Systems 9
Satisfiability and Validity
• A sentence is valid/ tautology if it holds under every interpretation.
• A sentence is satisfiable if it holds under some interpretation.
• A sentence is unsatisfiable/ contradiction if it holds under no interpretation.
Examples:
1. The sentence P (Q P) is valid.
2. The sentence (Q P) P is satisfiable.
3. The sentence P רP is unsatisfiable.
These examples can be proved using truth tables.
20
21
Dr. Mina Younan
Intelligent Systems 11
The syntax of the predicate calculus
Predicate calculus character set:
• The set of letters: a – z, and A – Z.
• The set of digits: 0, 1, …, 9.
• The underscore, _.
(2) Variables:
• They are used to designate general classes of objects or
properties in the world.
• Variables are represented by symbols beginning with an
uppercase letter.
• Examples of legal variables: X, Man, Bird, and DAY.
20
21
Dr. Mina Younan
Intelligent Systems 13
The syntax of the predicate calculus
(3) Functions:
• They denote a mapping of one or more elements in the domain of the
function into a unique element of the range of the function.
• Elements of the domain and range are objects in the world of
discourse.
• Function symbols begin with a lowercase letter.
• A function expression is a function symbol followed by its arguments
enclosed in parentheses and separated by commas.
• The number of arguments is called the arity of the function.
• Examples of well-formed function expressions:
Function expression f(X, Y) father(david) plus(2, 3)
Arity 2 1 2
20
21
Dr. Mina Younan
Intelligent Systems 14
The syntax of the predicate calculus
(4) Predicates:
• A predicate names a relationship between zero or more objects
or between objects and their properties in the world.
• Predicate symbols are symbols beginning with a lowercase
letter.
• Examples of predicates are:
likes, equals, on, near, part_of, clear.
• Predicates have an associated positive integer referred to as the
arity or the number of its arguments.
20
21
Dr. Mina Younan
Intelligent Systems 15
The syntax of the predicate calculus
An atomic sentence: is a predicate constant of arity n, followed
by n terms, t1, t2, …, tn, enclosed in parentheses and separated
by commas.
• A predicate calculus term is either a constant, variable, or
function expression. It may be used to denote objects and
properties in the problem domain.
• The truth values, true and false, are also atomic sentences.
• Examples of atomic sentences are:
likes (george, kate) likes (X, george)
likes (george, sarah, tuesday) likes (X, Y)
friends (bill, george) helps (richard, bill)
friends (father_of(david), father_of(andrew))
• Atomic sentences can be combined using logical connectives
(, , ר, , and ) to form sentences in the predicate calculus.
20
21
Dr. Mina Younan
Intelligent Systems 16
Variable quantifiers
• Variable quantifiers are symbols that constrain the meaning of a
sentence containing a variable. Quantifiers determine when predicate
calculus expressions are true.
• A quantifier Q is followed by a variable X and a sentence s: QXs.
• In the first order predicate calculus, there are two variable quantifiers:
o The universal quantifier, , indicates that the sentence is true for
all values of the variable.
For example, X likes (X, ice_cream) is true for all values in the
domain of the definition of X.
o The existential quantifier, , indicates that the sentence is true
for at least one value in the domain.
For example, Y friends (Y, peter) is true if there is at least one
person, indicated by Y, that is a friend of peter.
20
21
Dr. Mina Younan
Intelligent Systems 17
Predicate calculus sentences
Every atomic sentence is a sentence.
If s is a sentence, then so is its negation, רs.
If s1 and s2 are sentences, then so are their:
conjunction, s1 s2, disjunction, s1 s2,
implication, s1 s2, and equivalence, s1 s2.
If X is a variable and s is a sentence, then Xs is a sentence, and Xs is a
sentence.
Examples:
Let plus be a function symbol of arity 2 and let equal and foo be
predicate symbols with arity 2 and 3, respectively:
• plus (two, three) is a function and thus not an atomic sentence.
• equal (plus (two, three), five) is an atomic sentence.
• equal (plus (two, three), seven) is an atomic sentence. Note that this sentence
is false.
• X foo (X, two, plus (two, three)) equal (plus (two, three), five)
is a sentence, because both conjuncts are sentences.
20
21
Dr. Mina Younan
Intelligent Systems 18
Example:
• This is an example of the use of predicate calculus to describe a simple
world. The domain of discourse is a set of known family relationships:
mother (eve, abel)
mother (eve, cain)
father (adam, able)
father (adam, cain)
X Y (father (X, Y) mother (X, Y) parent (X, Y))
X Y Z (parent (X, Y) parent (X, Z) sibling (Y, Z))
• The predicates mother and father are used to define a set of parent-
child relationships. The implications give general definitions of other
relationships, such as parent and sibling, in terms of these predicates.
20
21
Dr. Mina Younan
Intelligent Systems 19
The function verify_sentence:
It is a recursive function for verifying that an expression is a sentence. It
takes as argument a candidate expression (E) and returns success if the
expression is a sentence.
function verify_sentence (E)
begin
case
E is an atomic sentence: return success;
E is of the form QXs, where Q is either or , and X is a variable:
if verify_sentence (s) returns success
then return success
else return fail;
E is of the form רs:
if verify_sentence (s) returns success
then return success
else return fail;
E is of the form s1 op s2, where op is a binary logical operator:
if verify_sentence (s1) returns success and
verify_sentence (s2) returns success
then return success
else return fail;
otherwise: return fail
end case
20
end.
21
Dr. Mina Younan
Intelligent Systems 20
Relationships between quantifiers ( ר, and )
20
21
Dr. Mina Younan
Intelligent Systems 21
Representing English sentences in predicate calculus
Examples:
• If it doesn't rain on Monday, Tom will go to the mountains.
רweather (rain, monday) go (tom, mountains)
• A bluebird is a blue-colored bird.
is_a (bluebird, bird) has_color (bluebird, blue)
• All basketball players are tall.
X (basketball_player (X) tall (X))
• Some people like anchovies.
X (person (X) likes (X, anchovies))
• If wishes were horses, beggars would ride.
equal (wishes, horses) ride (beggars)
• No body likes taxes.
רX likes (X, taxes)
20
21
Dr. Mina Younan
Intelligent Systems 22