This document discusses logic-based knowledge representation using propositional and predicate logic. It covers the syntax, semantics, and key concepts of both logics. For propositional logic, it defines propositional symbols, logical connectives, truth tables, and valid/satisfiable sentences. For predicate logic, it introduces predicates, variables, quantifiers, and how to form atomic and complex sentences using terms, predicates, and logical connectives. Variable quantifiers like universal and existential are also explained with examples.
2. Logic-based Knowledge Representation
• Different types of logic that can be used to represent knowledge are:
• Propositional calculus (or logic) PL.
• predicate calculus (or logic) some times called First order logic (FOL).
• Logic or belief.
• Logic can be defined as the study of correct inference, i.e. what follows from what.
2
3. Logic-based Knowledge Representation
• Logic usually consists of syntax, semantics and a proof theory.
• The syntax of logic defines a formal language of the logic.
• The semantics of logic specifies the meanings of the well-formed expressions of
the logical language.
• Semantics is the study of meaning
• The proof theory of logic provides a purely formal specification of the notion of
correct inference.
• This chapter introduces the propositional calculus and the predicate calculus as logic-
based knowledge representation languages for AI.
3
4. The Propositional Calculus
1) The syntax of the propositional calculus:
The first step in describing a language is to introduce its set of symbols.
Propositional calculus symbols are:
the propositional symbols: P, Q, R, S, … (uppercase letters near the end of the
English alphabet)
truth symbols or logical constants: true, false
Logical connectives: , , ר, ,
Propositional symbols denote propositions, or statements about the world that may be
either true or false, such as "the car is red".
4
5. Rules of forming legal propositional calculus sentences:
1. Every single propositional symbol and truth symbol is called atomic sentence.
e.g. true, P, Q, and R are sentences.
2. The negation of atomic sentence is a complex sentence.
e.g. רP and רfalse are complex sentences.
3. The conjunction, i.e. and, of two atomic sentence is a complex sentence.
e.g. P Q is a complex sentence.
4. The disjunction, i.e. or, of two atomic sentence is a complex sentence.
e.g. P Q is a complex sentence.
5. The implication of one sentence from another is a complex sentence.
e.g. P Q is a complex sentence.
6. The equivalence of two atomic or complex sentence is a complex sentence.
e.g. P Q R is a complex sentence.
• Legal sentences are also called well-formed formulas or WFFs.
5
6. 6
In P Q, is pronounced P and Q, P and Q are called conjuncts.
In P Q, is pronounced P or 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.
• Ex: if it rainy, the earth would be wet
@Sinaiunieg www.su.edu.eg
info@su.edu.eg
Rules of forming legal propositional
calculus sentences:
7. The semantics of propositional calculus is defined as follows:
Semantics of PL is the interpretation of the propositional symbols (P, Q, R,…) and
logical constants (true, false) and specifying the meaning of the logical connectors (ר,
, , , ).
An interpretation of a set of propositions is the assignment of a truth value, either T or
F, to each propositional symbol.
Formally, an interpretation is a mapping from the propositional symbols into the set
{T, F}.
A propositional symbol corresponds to a statement about the world.
EX:- P may denote the statement “it is raining” or “Paris is the capital of France”.
Note that, the symbols true and false (logical constants) 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.
7
Rules of forming legal propositional calculus sentences:
2) The semantics of the propositional calculus:
8. Where we have only two truth values (i.e. T or F) as an interpretation
for each propositional symbol, then if we have n propositional symbols,
we can define 𝟐𝒏 different interpretations.
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.
8
Rules of forming legal propositional
calculus sentences:
9. The interpretation or truth value assignment for sentences is determined as follows:
Condition
Truth value assignment
Sentence
T
true
F
false
If P has truth value F.
If P has truth value T.
T
F
רP
If both P and Q has truth value T.
Otherwise.
T
F
P Q
If both P and Q has truth value F.
Otherwise.
F
T
P Q
If P is T and Q is F.
Otherwise.
F
T
P Q
If P and Q have the same truth value
assignments for all possible
interpretations.
Otherwise.
T
F
P Q
9
10. • The truth assignments of compound propositions are often described by truth tables.
Example: The truth table for P Q: P Q
Q
P
T
T
T
F
F
T
T
T
F
T
F
F
P Q רP Q
P Q
רP Q
רP
Q
P
T
T
T
F
T
T
T
F
F
F
F
T
T
T
T
T
T
F
T
T
T
T
F
F
10
The truth tables for , , ר, and can be defined in
a similar fashion.
The equivalence of two expressions may be
demonstrated using truth tables.
Example: A proof of the equivalence of P Q and רP Q:
11. Satisfiability and Validity
• A sentence is valid if it holds under every interpretation.
A valid sentence is called a tautology.
• A sentence is satisfiable if it holds under some interpretation.
• A sentence is unsatisfiable if it holds under no interpretation. An unsatisafiable
sentence is called a contradiction.
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.
11
12. The 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.
Predicate calculus provides this ability.
A predicate is a parameterized proposition, that is a proposition with parameters/variables.
Predicate Logic deals with predicates, which are propositions containing variables.
For example, instead of letting a single propositional symbol, P, denote the entire sentence
"It rained on Tuesday", we can create a predicate weather that describes a relationship
between a date and the weather: weather (tuesday, rain).
Through inference rules we can manipulate predicate calculus expressions, accessing their
individual components and inferring new sentences.
Predicate calculus also allows expressions to contain variables.
Variables let us create general assertions about classes of entities.
For example we could state that for all values of X, where X is a day of the week, the statement
weather (X, rain) is true, i.e., it rains every day.
12
13. The syntax of the predicate calculus
Predicate calculus character set:
• The set of letters: a – z, and A – Z.
• They refer to objects without naming.
• Small letters refer to constant objects, while uppercase letters refers to variable
objects.
• The set of digits: 0, 1, …, 9.
• The underscore, _.
Logical connectors: Logical connectives: , , ר, ,
• Variable quantifiers: ,
• (Universal quantifier) for all
• (Existential quantifier) there exist
13
14. Predicate calculus symbols:
• Symbols in the predicate calculus begin with a letter and are followed by any sequence
of the legal characters mentioned above. No blanks allowed.
• Examples of legal predicate calculus symbols:
george fire3 tom_and_jerry bill XXX friends_of
• Examples of strings that are not legal predicate symbols:
3jak "no blanks allowed" ab%cd **71 duck!!
• Symbols are used to denote objects, properties, or relations in a world of discourse.
• Predicate calculus symbols may represent
1- Objects (either constants or Variables).
2- Relations (sometimes called predicates).
3- Functions.
• Objects and functions are known as terms.
14
The syntax of the predicate calculus
15. (1) Constants:
• They name specific objects or properties in the world.
• Constant symbols must begin with a lowercase letter.
• Examples of legal constant symbols:
george, tree, tall, and blue.
• The constants true and false are reserved as truth symbols.
(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.
15
The syntax of the predicate calculus
16. (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
• Each function expression denotes the mapping of the 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.
16
The syntax of the predicate calculus
17. (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.
17
The syntax of the predicate calculus
18. • Different between predicates (relations) and functions
• father (ahmed) , it is result may be Hussein (function)
• plus(one, two) , it is result is three (function)
• married(john, mary), it is result may be true (predicate – relation)
• Predicate give you true or false based on your input(s). While a function gives you an output per your
input(s).
18
The syntax of the predicate calculus
19. • An atomic sentence: is formed from a predicate symbol followed by list of terms t1, t2,
…, tn, enclosed in parentheses and separated by commas. So it is a predicate of arity n.
• 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.
• Atomic Sentence = predicate (term1,.....,termn)
or term1 = term2
• Examples:
large_than(2,3) is false.
brother_of(Mary,Pete) is false.
married(father(Richard),mother(John)) could be true or false.
• Note: Functions do not state facts and form no sentence:
Brother(Pete) refers to John (his brother) and is neither true nor false
• The truth symbols, true and false, are also atomic sentences.
19
Predicate calculus sentences
21. Predicate calculus sentences
• We make complex sentence with connectives (just like in propositional logic).
• Complex sentences: we can use logical connectors (, , ר, , and ) to construct
more complex sentences, with the same syntax and semantics as in propositional
calculus.
• If 𝑆 is a sentence, then so is its negation, ר 𝑆 is a complex sentence.
• If 𝑆1 and 𝑆2 are sentences, then so are their:
conjunction, 𝑆1 𝑆2, disjunction, 𝑆1 𝑆2 are complex sentences,
implication, 𝑆1 𝑆2, and equivalence, 𝑆1 𝑆2 are complex sentences.
• Examples of complex sentences
• Brother(Richard, John) ∧ Brother(John, Richard)
• King(Richard) ∨ King (john)
• King(John)=> ᆨKing(Richard)
• LessThan(plus(1,2),4)∧GreaterThan(1,2)
21
22. Predicate calculus sentences
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 complex
sentence.
22
23. Variable quantifiers
23
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:
The universal quantifier, , indicates that the sentence is true for all values of the
variable. It allows us to make a statement about a collection of objects.
For example,
• All cats are mammals
x:cat(x) mammal(x)
• X likes (X, ice_cream) is true for all values in the domain of the definition of X.
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.
24. Variable quantifiers examples
24
Here some examples of variable quantifiers:
George is a monkey and he is curious
monkey (george) curious (george)
Monkeys are curious
m: monkey(m) curious(m)
There is a curious monkey
m: monkey(m) curious(m)
There exists an object that is either a curious monkey, or not a monkey at all
m: (monkey(m) curious(m)) ( רmonkey(m)), or
m: monkey(m) curious(m)
26. Properties of variable quantifiers
26
For predicates p and q and variables X and Y:
1) x,y is the same as x y
2) x,y is the same as x y
3) x y is the same as y x
4) x y is the same as y x
5) x y is not the same as y x
Examples:
“there is a person who loves everyone in the world”
x y loves (x, y)
“Everyone in the world is loved by at least one person”
y x loves (x, y)
6) Quantifier duality
• x p(x) ר x רp(x)
• x p(x) רx רp(x)
27. Properties of variable quantifiers
27
7) Demogan’slaws
• רx p(x) x רp(x)
• ר x p(x) x רp(x)
28. 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)
or X רlikes (X, taxes)
• No body is right if everybody is wrong.
X (ר right (X) wrong (X))
28
30. 30
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))
These implications can be used to infer facts such as
sibling (abel, cain).
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.
31. 31
Several relationships between negation and the universal and the existential quantifiers are
given below. Also, the notion of a variable name as a dummy symbol that stands for a set
of constants is noted.
For predicates p and q and variables X and Y:
רX p(X) X רp(X)
רX p(X) X רp(X)
X p(X) Y p(Y)
X q(X) Y q(Y)
X (p(X) q(X)) X p(X) Y q(Y)
X (p(X) q(X)) X p(X) Y q(Y)
32. THANK YOU
For any questions feel free
to contact me by mail
Gh_mcs86@yahoo.com