Symbols (continued)

advertisement
ARTIFICIAL INTELLIGENCE
[INTELLIGENT AGENTS PARADIGM]
SYNTAX OF PREDICATE
CALCULUS
Professor Janis Grundspenkis
Riga Technical University
Faculty of Computer Science and Information Technology
Institute of Applied Computer Systems
Department of Systems Theory and Design
E-mail: Janis.Grundspenkis@rtu.lv
Syntax of Predicate Calculus
• Predicate calculus provides more
flexibility and a finer representation
of the knowledge.
For example, A = ball’s color is yellow propositional calculus representation
Color(ball, yellow) – predicate calculus
representation
Syntax of Predicate Calculus
B = It rained on Tuesday - propositional calculus
representation
Weather(Tuesday, rain)
Weather(X, rain), where X is
a day of a week
predicate calculus
representation
This representation enhances knowledge
processing by allowing the use of variables
and functions.
Syntax of Predicate Calculus
Symbols
Predicate calculus symbols are irreducible syntactic
elements: they cannot be broken into their
component parts by the operations.
The alphabet that makes up the symbols consists of:
1. The set of letters, both upper- and lowercase
2. The set of digits, 0, 1, ..., 9
3. The underscore, _
Syntax of Predicate Calculus
Symbols (continued)
Symbols begin with the letter and are
followed by any sequence of these legal
symbols.
For example, Agent007, father of, XXXXX,
tom_and_jerry.
All these strings are legal symbols.
Syntax of Predicate Calculus
Symbols (continued)
Contrary,
007agent, tom@cs.lv, ab%cd, #duck,
are examples of strings that are not legal
symbols.
Improper symbols “( )”, “,”, “.”
do not denote objects or relations in the world,
but are used solely to construct wellformed expressions.
Syntax of Predicate Calculus
Symbols (continued)
Symbols may represent
• constants are used to name specific
objects or properties.
In general, constants are symbols that
begin with a lowercase letter.
Syntax of Predicate Calculus
Symbols (continued)
For example, the constant tom may
represent the object Tom, a person in
the domain.
The constants true and false are reserved
as truth symbols.
Syntax of Predicate Calculus
Symbols (continued)
• Predicates
A fact or proposition is divided into two
parts:
a predicate
and an argument
The argument represents the object or
objects of the proposition and the
predicate an assertion about the object.
Syntax of Predicate Calculus
Symbols (continued)
For example, to represent the proposition
“Tom owns a car” we would write:
owns(tom, car)
Arguments are symbols
denoting objects
within the problem
Predicate denotes some
relationship between arguments
Syntax of Predicate Calculus
Symbols (continued)
• Variables
Variables are used to represent general
classes of objects or properties in the
world.
For example, to capture the propositions
“Tom likes Ann” and “Bob likes Mary”,
we can write
likes(X, Y)
Syntax of Predicate Calculus
Symbols (continued)
In this case, variables assume or
instantiate the values
X = {tom, bob}; Y = {ann, mary}.
Variables can be used as arguments in a
predicate expression or a function
Syntax of Predicate Calculus
Symbols (continued)
• Functions
Function denotes a mapping of one or
more elements in a set (called the
domain of the function) to a unique
element of another set (the range of
the function).
Syntax of Predicate Calculus
Symbols (continued)
Elements of the domain and range are
objects in the world of discourse.
Every function symbol has an associated
arity, indicating the number of
elements in the domain mapped onto
each element of the range.
Syntax of Predicate Calculus
Symbols (continued)
A function expression consists of a
function constant of arity n, followed
by n terms (arguments), t1, t2, ..., tn,
enclosed in parentheses and separated
by commas.
Syntax of Predicate Calculus
Symbols (continued)
A term is either a constant, variable, or
function expression.
Examples: price(apples), father(tom);
father(bill), left_foot_of_(tom),
minus(7, 3), f(X, Y, Z)
Syntax of Predicate Calculus
Symbols (continued)
Each function expression denotes the
mapping of arguments onto a single
object in the range, called the value
of the function.
The act of replacing a function with its
value is called evaluation.
Syntax of Predicate Calculus
Symbols (continued)
Example: father(tom) = bob; father(bill) =
john
Function can be used within predicates:
colleagues(father(tom), father(bill))
After the function expressions are evaluated,
the expresion becomes:
colleagues(bob, john)
Syntax of Predicate Calculus
Atomic Sentences
Predicates have an associated positive integer
referred to as the arity or “argument number”
for the predicate.
Predicates with the same name but different arities
are considered distinct.
An atomic sentence is a predicate constant of arity
n, followed by n terms, t1, t2, ..., tn, enclosed in
parentheses and separated by commas.
Syntax of Predicate Calculus
Atomic Sentences (continued)
The truth values, true and false, are also atomic
sentences.
Atomic sentences are also called atomic
expressions, atoms, or propositions.
Examples: equal(minus(7, 3), seven) is an atomic
sentence
equal(minus(seven, three), four) is an atomic
sentence
minus(seven, three) is not an atomic sentence.
Syntax of Predicate Calculus
Complex Sentences
Atomic sentences can be combined using
logical operators to form complex
sentences:
Every atomic sentence is a sentence S.
1. If S is a sentence, then so is S.
2. If S1 and S2 are sentences, then so is
S1  S2.
Syntax of Predicate Calculus
Complex Sentences (continued)
3. If S1 and S2 are sentences, then so is
S1  S2.
4. If S1 and S2 are sentences, then so is
S1  S2.
5. If S1 and S2 are sentences, then so is
S1  S2.
Syntax of Predicate Calculus
Complex Sentences (continued)
Example: likes(bob, mary) atomic sentences
likes(george, mary)
likes(bob, mary)  likes(george, mary) 
likes(bob, george)
Syntax of Predicate Calculus
Complex Sentences (continued)
Or, general implication
likes(X, Y)  likes(Z, Y)  likes(X, Z)
Captures the knowledge
“If two different individuals like the
same person, then they dislike each
other”
Syntax of Predicate Calculus
Complex Sentences (continued)
When a variable appears as an argument
in a sentence, it refers to unspecified
objects in the domain.
Syntax of Predicate Calculus
Complex Sentences (continued)
Predicate calculus includes two other
symbols called variable quantifiers
 and , that are used to define the
range or scope of the variable in a
logical expression. In other words,
variable quantifiers constrain the
meaning of a sentence containing a
variable.
Syntax of Predicate Calculus
Complex Sentences (continued)
The universal quantifier, , indicates that
the sentence is true for all values of the
quantified variable.
For example, statement “Everybody likes
Mary” may be written like
X likes(X, mary)
and it is true for all values of X.
Syntax of Predicate Calculus
Complex Sentences (continued)
If X = { john, paul, george, ringo }, then
likes(john, mary)  likes(paul, mary) 
likes(george, mary)  likes(ringo, mary)
In general,
X p(X)  p(x1)  p(x2)  ...  p(xn)
any predicate
Syntax of Predicate Calculus
Complex Sentences (continued)
The existential quantifier, , indicates that sentence
is true for some value(s) in the domain, i.e., at
least one value “exists” that makes the sentence
true.
For example, the statement “At least someone likes
ice cream” may be written like
X likes(X, ice_cream)
and it is true for at least one (but not necessarily
exactly one!) object, indicated by the variable X.
Syntax of Predicate Calculus
Complex Sentences (continued)
If Y = { john, paul, george, ringo }, and we know
that the first two like ice cream and the second
two not, then variable X instantiate all these
constants, and two statements, namely
likes(john, ice_cream) and likes(paul, ice_cream)
are true, while
likes(george, ice_cream) and likes(ringo, ice_cream)
are false.
If general, X p(X)  p(x1)  p(x2)  ...  p(xn)
any predicate
Syntax of Predicate Calculus
Complex Sentences (continued)
6. If X is a variable and s a sentence, then
Xs is a sentence.
7. If X is a variable and s a sentence, then
Xs is a sentence.
Parentheses are used to indicate the scope of
quantification, that is, the range over
which the instances of the variable hold.
Syntax of Predicate Calculus
Complex Sentences (continued)
Examples: a) X (cat(X)  animal(X))
This logical expression represents the statement
“All cats are animals”.
b) X (likes(X, mary)  nice(mary) 
nice(X))
This logical expression determines all instances
of X who like Mary, and if Mary is nice, then it
is implied that those who like Mary are also
nice.
Syntax of Predicate Calculus
Complex Sentences (continued)
c) X, Y (parent(X, Y)  child(Y, X)
This logical expression represents the
statement “For all persons, if X is a parent
of Y, then Y is a child of X”.
d) X Y loves(X, Y)
This logical expression represents the
statement “Everybody loves somebody”.
Syntax of Predicate Calculus
Complex Sentences (continued)
e) Y X loves(X, Y)
This logical expression represents the
statement “Somebody is loved by
everybody”.
Download