L02 - Knowledge-Rep - Part 2
L02 - Knowledge-Rep - Part 2
1
Content
• Logical Knowledge Representation
• Propositional Logic
• First Order Predicate Logic
2
Logical Knowledge Representation
Oldest form of KR
in computer
Concerned with
truthfulness
Manipulate
BICONDITIO
Boolean AND OR NOT IMPLIES
NAL
operators
3
3
Logical Knowledge Representation
• Using propositional Logic & First Order Logic.
• Logic make statements about the world which
are true or false.
• Logic is defined by:
o Syntax (possible configurations of sentences)
o Semantics (interpretation)
o Proof theory (entailment to derive new fact)
4
4
Propositional Logic (PL)
• PL (or propositional calculus) - is a branch of
mathematical logic that studies the logical
relationships between propositions, or
statements that are either true or false.
• PL - uses symbols to represent propositions
and logical connectives to link propositions
together to form compound propositions.
5
Propositional Logic (PL)
• Compound proposition is made up of
operators and >1 elementary
propositions
• Boolean operators
– AND (ꓥ), OR (ꓦ), NOT(¬), BICONDITIONAL (),
IMPLIES(→)
6
Intro to Propositional Logic
it_is_raining
elementary (P)
proposition
E.g.
kitty_gets_wet kitty_is_outside
(Q) (R)
7
7
Propositional logic
• Logical constants: true, false
• Propositional symbols: P, Q, S, ...
• Wrapping parentheses: ( … )
• Sentences are combined by connectives:
...and
...or
...implies
..is equivalent
...not
88
Propositional logic (PL)
• A simple language useful for showing key
ideas and definitions
• User defines a set of propositional
symbols, like P and Q.
• User defines the semantics of each of
these symbols, e.g.:
– P means "It is hot"
– Q means "It is humid"
– R means "It is raining"
99
Operator and Symbol for PL
General Name Formal Name Symbol
Not Negation
And Conjunction
Or Disjunction
If…
Then/Implies
Conditional
If and only if Biconditional
10
Examples of PL sentences
• (P ^ Q) => R : “If it is hot and humid,
then it is raining”
• Q => P : “If it is humid, then it is hot”
• Q : “It is humid.”
11
11
Operator and Symbol
• The use of bracket “(…)” will affect the
meaning of the whole PL representation
• Example:
(A ^ B) v C
A ^ (B v C)
• Shows the boundary of each operator
12
Operators and PL
• The most important operator will be
selected as the principal operator.
(A ^ B) (C v D)
13
Example
Word Representation
Today is hot h
I feel dehydrate d
I need to drink water w
15
Propositional Logic and Truth Table
• PL truth can be determined with a truth table using the
following:
• Tautology (Valid)
– Sentence that is True under all interpretations
– E.g. (P(PQ))Q
• Contingent (Satisfiable)
– Sentence is sometimes T sometimes F
– E.g. (AB)C
• Inconsistent (Unsatisfiable)
– Formula is always F
– E.g. P(P)
16
Truth table – proving PL
• Example: the truth value of a statement
written in PL.
P Q P PQ PQ PQ PQ
T T F T T T T
T F F F T F F
F T T F T T F
F F T F F T T
17
17
Limitation of PL
• Consider the following statement:
– “If Comel is meowing, then Comel is a cat. Comel is
meowing, therefore Comel is a cat”
– PL: ((comel_meowing → comel_isa_cat) Ʌ
comel_meowing) → comel_isa_cat
• How about this: is any_meowing or any_isa_cat refer
to “comel”?
– “Any that meowing is a cat”
– PL: ((any_meowing → any_isa_cat) Ʌ comel_meowing) →
comel_isa_cat
18
Propositional Logic Limitation
1. Cannot express universality of objects
• E.g.
• “all computers have processor”
• “all birds flly”
• parrot_flies canary_flies
backyard_bird_flies ………..
19
19
Propositional Logic Limitation
2. Cannot express existence / inexistence / partial
quantity of objects
• E.g.
• “some UMS students are international
students”
• “none of us is immortal”
Solution
Functor
23
23
Structure of Predicate
• functor(argument1, argument2,
…, argumentN)
Structure
Describing:
name of relation / adjective / verb / possession
24
24
Relationship becomes functor
likes(she,chocolate)
25
25
Variations of predicates
• likes(she, chocolate)
• teaches(X, Y)
• likes(X, chocolate)
• likes(she, What)
• teaches(bob, Course)
• teaches(Who, comp1013)
• teaches(bob, _)
• teaches(X, comp1013, monday)
26
Quantifier
Expression true
for ALL values of X X (bird(X)
‘for all’
designated likes(X,icecream) flies(X))
variables
27
27
Quantifier
X
‘there Expression true
X (bird(X)
exist’. for SOME
values of likes(X,icecream) flies(X))
designated
variables
28
28
More examples
• E.g. 1:
– Normal: If it doesn’t rain today, Ahmad will go to the
beach
– FOPL: “rain(today) go(ahmad, beach)”
• E.g. 2:
– Normal: All volleyball players are tall
– FOPL: “X (volleyball_player (X) tall (X))”
• E.g. 3:
– Normal: Some people like durian.
– FOPL: “X (person(X) likes(X, durian))”
• E.g. 4:
– Normal: Nobody likes war
– FOPL: “ X likes (X, war)” OR “X likes(X,war)” 29
29
Practice converting English to first-
order logic
• “John has an umbrella”
– y (Has(John, y) IsUmbrella(y))
• “Anything that has an umbrella is not wet”
– x y Has(x, y) IsUmbrella(y) => IsWet(x)
• “Any person who has an umbrella is not wet”
– x IsPerson(x) => ( y Has(x, y) IsUmbrella(y) =>
IsWet(x))
30
Practice converting English to first-
order logic
• “John has at least two umbrellas”
– x, y Has(John, x) IsUmbrella(x)
Has(John, y) IsUmbrella(y) (x=y)
31
Proving FOPL
• Truth table can be used only for short
sentence and impractical for complex
sentence.
• FOPL proving – using deduction or
resolution
• (Next chapter…)
32
Summary
• Propositional logic and FOPL are two popular knowledge
representation techniques used in artificial intelligence.
• PL is suitable for representing simple and static knowledge,
while FOPL is suitable for representing complex and dynamic
knowledge.
• FOPL provides more expressive power than propositional
logic and allows for the representation of variables,
quantifiers, and functions.
• Both propositional logic and FOPL allow for the use of
inference rules to derive new knowledge from existing
knowledge.
33