5. PROPOSITIONAL
LOGIC
⚫Repesented in Formal language
Syntax
□ A well-formed formula (wff) in propositional
logic is:
(1)An atom is a wff
(2)If P is a wff, then ~P is a wff.
(3)If P and Q are wffs then P∧Q, P∨Q, P→Q &
P↔Q are wffs.
(4)The set of all wffs can be generated by
repeatedly applying rules (1)..(3).
3
4
6. PROPOSITIONAL LOGIC: SYNTAX
□Propositional logic is the simplest logic
□The proposition symbols S1, S2 etc are sentences
⚫If S is a sentence, ¬S is a sentence (negation)
⚫If S1 and S2 are sentences, S1 ∧ S2 is a sentence (conjunction)
⚫If S1 and S2 are sentences, S1 ∨ S2 is a sentence (disjunction)
⚫If S1 and S2 are sentences, S1 ⇒ S2 is a sentence (implication)
⚫If S1 and S2 are sentences, S1 ⇔ S2 is a sentence (biconditional)
7. PROPOSITIONAL LOGIC: SEMANTICS
Each model specifies true/false for each proposition symbol
E.g.
With these symbols, 8 possible models, can be enumerated
automatically.
Rules for evaluating truth with respect to a model m:
¬S is true iff S is false
S1 ∧ S2is true iff S1 is true and S2 is true S1 ∨
S2 is true iff S1is true or S2 is true
S1 ⇒ S2is true iff S1 is false or S2 is true
i.e., is false iff S1 is true and S2 is false
1
S1 ⇔ S2 is true iff S ⇒S2 is true and
2
5
6
9. LOGICAL EQUIVALENCE
• □ Two sentences are logically equivalent} iff true in same models
• : α ≡ ß iff α╞ β and β╞ α
10. VALIDITY AND SATISFIABILITY
7
A sentence is valid if it is true in all
models,
e.g., True, A ∨¬A, A ⇒ A, (A ∧ (A ⇒
B)) ⇒ B
Validity is connected to inference via the
Deduction Theorem:
KB ╞ α if and only if (KB ⇒ α) is valid
A sentence is satisfiable if it is true in some model
e.g., A∨ B, C
A sentence is unsatisfiable if it is true in no models
e.g., A∧¬A
Satisfiability is connected to inference via the
following:
KB ╞ α if and only if (KB ∧¬α) is unsatisfiable
8
13. CNF, DNF
□Conjunctive normal form (CNF)
F1 … ∧Fn,
∧Fi , i=1,n
□Disjunctive normal form (DNF)
F1 ∨ … ∨Fn, Fi , i=1,n
11
CONVERSION TO CLAUSE FORM
1.Convert all the propositions of KB to clause form
(S).
2.Negate α and convert it to clause form. Add it to S.
3.Repeat until either a contradiction is found or no
progress can be made.
a. Select two clauses (α ∨ ¬P) and ( γ ∨ P).
b. Add the resolvent (α ∨ γ) to S.
12
14. WUMPUS WORLD
13
❖We must explore a cave consisting of rooms
connected by passageways.
❖Lurking somewhere in the cave is a beast (the
wumpus) that eats anyone who enters his room.
❖Some rooms contain bottomless pits, but another
contains gold.
14
17. 17
PROS AND CONS OF PROPOSITIONAL
LOGIC
☺ Propositional logic is declarative
⚫Propositional logic allows
⚫partial/disjunctive/negated information
☺ Meaning in propositional logic is context-
Independent
⚫(unlike natural language, where meaning
depends on context)
☹ Propositional logic has very limited expressive
Power
⚫(unlike natural language)
18
18. □Whereas propositional logic assumes the world contains facts,
□first-order logic (like natural language) assumes the world contains
⚫Objects: people, houses, numbers, colors, baseball games, wars, …
⚫Relations: round, prime, brother of, bigger than, part of, comes between,
…
⚫Functions: Gt(), Lt(), Age=Curr-DOB…
20
FIRST ORDER PREDICATE LOGIC
19. • It has three more logical notions as compared to PL.
• – Terms, Predicates and Quantifiers
● Term
–a constant (single individual or concept i.e.,5, john etc.),
–a variable that stands for different individuals
–n-place function f(t1, …, tn) where t1, …, tn are terms.
–A function is a mapping that maps n terms to a term.
● Predicate
–a relation that maps n terms to a truth value true (T) or false (F).
● Quantifiers
–Universal or existential quantifiers i.e. ∀ and ∃ used in
–conjunction with variables.
• 19
PREDICATE LOGIC
20. UNIVERSAL QUANTIFICATION
□∀x P(x)
□Example: “Everyone at UNC is smart”
∀x At(x,UNC) ⇒ Smart(x)
□Roughly speaking, equivalent to the conjunction of
all possible instantiations of the variable:
At(John, UNC) ⇒ Smart(John) ∧ ...
At(Richard,UNC) ⇒ Smart(Richard) ∧ ...
□∀x P(x) is true in a model m iff P(x) is true with x
being each possible object in the model
21
22
21. EXISTENTIAL QUANTIFICATION
□ ∃x P(x)
□ Example: “Someone at UNC is smart”
• ∃x At(x,UNC) ∧ Smart(x)
□ Roughly speaking, equivalent to the disjunction of all possible instantiations:
• [At(John,UNC) ∧ Smart(John)] ∨
• [At(Richard,UNC) ∧ Smart(Richard)] ∨ …
□ ∃x P(x) is true in a model m iff P(x) is true with x being some possible
object in the model
22. PROPERTIES OF QUANTIFIERS
□∀x ∀y is the same as ∀y ∀x
□∃x ∃y is the same as ∃y ∃x
□∃x ∀y is not the same as ∀y ∃x
“There is a person who loves everyone”
∃x ∀y Loves(x,y)
“Everyone is loved by at least one person”
∀y ∃x Loves(x,y)
□Quantifier duality: each quantifier can be
expressed using the other with the help of negation
∀x Likes(x,IceCream) ¬∃x ¬Likes(x,IceCream)
∃x Likes(x,Broccoli) ¬∀x ¬Likes(x,Broccoli)
23
24
26. GENERALIZED MODUS PONENS (GMP)
p1', p2', … , pn', ( p1 ∧ p2 ∧ … ∧ pn ⇒q)
Subst(θ,q)
where pi'θ = pi θ for all i
□GMP used with KB of definite clauses (positive literal)
□All variables assumed universally quantified
27
28
27. UNIVERSAL INSTANTIATION (UI)
• □ A universally quantified sentence entails every instantiation
of it:
∀v P(v)
SUBST({g/v}, P(v))
• for any variable v and ground term g
□ E.g., ∀x King(x) ∧ Greedy(x) ⇒ Evil(x) yields:
King(John) ∧ Greedy(John) ⇒ Evil(John)
King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard)
King(Father(John)) ∧ Greedy(Father(John)) ⇒
Evil(Father(John))
28. EXISTENTIAL INSTANTIATION (EI)
□An existentially quantified sentence entails the
instantiation of that sentence with a new constant:
∃v P(v)
SUBST({C/v}, P(v))
for any sentence P, variable v, and constant C that
does not appear elsewhere in the knowledge base
□E.g., ∃x Crown(x) ∧ OnHead(x,John) yields:
Crown(C1) ∧ OnHead(C1,John)
provided C1 is a new constant symbol, called a Skolem
constant
29
SUBST(θ,q) is Evil(John) 30
29. GENERALIZED MODUS PONENS (GMP)
• p1', p2', … , pn', (p1 ∧ p2 ∧ … ∧ pn ⇒q)
• such that SUBST(θ, pi')= SUBST(θ, pi) for all I
• SUBST(θ,q)
Used with definite clauses (exactly one positive literal)
□ All variables assumed universally quantified
□ Example:
• p1' is King(John) p1 is King(x) p2' is Greedy(y) p2
is Greedy(x) θ is {x/John,y/John}
• q is Evil(x)
30. EXAMPLE KNOWLEDGE
BASE
□The law says that it is a crime for an
American to sell weapons to hostile
nations. The country Nono, an enemy of
America, has some missiles, and all of its
missiles were sold to it by Colonel West,
who is American.
□Prove that Col. West is a criminal
31
32
31. EXAMPLE KNOWLEDGE BASE
• It is a crime for an American to sell weapons to hostile nations:
• ∀ x ∀ y ∀ z American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧
Hostile(z) ⇒ Criminal(x)
• Nono has some missiles
• ∃y Owns(Nono,y) ∧ Missile(y) Owns(Nono,M1) Missile(M1)
• All of its missiles were sold to it by Colonel West
• ∀y Missile(y) ∧ Owns(Nono,y) ⇒ Sells(West,y,Nono) Missile(M1) ∧ Owns(Nono, M1) ⇒
• Sells(West, M1,Nono)
• West is American
• American(West)
• The country Nono is an enemy of America
Enemy(Nono,America)
General KW
Missiles are weapons:
• ∀y Missile(y) ⇒ Weapon(y) Missile(M1) ⇒
• Weapon(M1)
• An enemy of America counts as “hostile”:
• ∀z Enemy(z,America) ⇒ Hostile(z) Enemy(Nono,America) ⇒ Hostile(Nono)
32. USING PREDICATE LOGIC
1.
8.
1.Marcus was a man.
2.Marcus was a Pompeian.
3.All Pompeians were Romans.
4.Caesar was a ruler.
5.All Pompeians were either loyal to Caesar or
hated him.
6.Every one is loyal to someone.
7.People only try to assassinate rulers they are not
loyal to. Marcus tried to assassinate Caesar.
33
34
1.
33. 1.Marcus was a man. man(Marcus)
2.Marcus was a Pompeian. Pompeian(Marcus)
3.All Pompeians were Romans.
∀x: Pompeian(x) → Roman(x)
4.Caesar was a ruler. ruler(Caesar)
5.All Pompeians were either loyal to Caesar or hated him. inclusive-or
∀x: Roman(x) → loyalto(x, Caesar) ∨ hate(x, Caesar)
exclusive-or
∀x: Roman(x) → (loyalto(x, Caesar) ∧ ¬hate(x, Caesar)) ∨(¬loyalto(x, Caesar) ∧
hate(x, Caesar))
USING PREDICATE LOGIC
34. USING PREDICATE LOGIC
6. Every one is loyal to someone.
∀x: ∃y: loyalto(x, y) ∃y: ∀x: loyalto(x, y)
39
7.
7.People only try to assassinate rulers they are not
loyal to.
40
∀x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y)
→ ¬loyalto(x, y)
8.Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)
Was Marcus loyal to Caesar?
man(Marcus) ruler(Caesar)tryassassinate(Marcus, Caesar)
⇓
∀x: man(x) → person(x)
¬loyalto(Marcus, Caesar)
35. RESOLUTION REFUTATION IN PREDICATE
LOGIC
●Resolution method is used to test unsatisfiability of
a set S of clauses in Predicate Logic.
●It is an extension of resolution method for PL.
●The resolution principle basically checks whether
empty clause is contained or derived from S.
●Resolution for the clauses containing no variables
is very simple and is similar to PL.
●It becomes complicated when clauses contain variables.
●In such case, two complementary literals are resolved after
proper substitutions so that both the literals have same
arguments.
37. CONVERSION TO CLAUSE FORM
4.
5.
6.
7.
8.
9.
1.Eliminate →.
2.Reduce the scope of each ¬ to a single term.
3. Standardize variables so that each quantifier binds a
unique variable. 4.Move all quantifiers to the left
without changing their relative order. 5.Eliminate ∃
(Skolemization).
6.Drop ∀.
7.Convert the formula into a conjunction of disjuncts.
Create a separate clause corresponding to each
conjunct.
8.Standardize apart the variables in the set of obtained
clauses.
49
50
1.
2.
3.
38. CONVERSION TO CLAUSE FORM
• Eliminate →.
P → Q ≡ ¬P ∨ Q
• Reduce the scope of each ¬ to a single term.
¬(P ∨ Q) ≡ ¬P ∧ ¬Q
¬(P ∧ Q) ≡ ¬P ∨ ¬Q
¬∀x: P ≡ ∃x: ¬P
¬∃x: p ≡ ∀x: ¬P
¬¬ P ≡ P
• Standardize variables so that each quantifier binds a unique variable
• (∀x: P(x)) ∨ (∃x: Q(x)) ≡ (∀x: P(x)) ∨ (∃y: Q(y))
39. CONVERSION TO CLAUSE FORM
4.
Move all quantifiers to the left without changing their
relative order.
(∀x: P(x)) ∨ (∃y: Q(y)) ≡ ∀x: ∃y: (P(x) ∨ (Q(y))
Eliminate ∃ (Skolemization).
5.
∃x: P(x) ≡ P(c)
Skolem constant
∀x: ∃y P(x, y) ≡ ∀x:
P(x, f(x))
Skolem function
6.
7.
Drop ∀.
∀x: P(x) ≡ P(x)
Convert the formula into a conjunction of disjuncts.
(P ∧ Q) ∨ R ≡ (P ∨ R) ∧ (Q ∨ R)
8.Create a separate clause corresponding to each conjunct.
9.Standardize apart the variables in the set of obtained
clauses. 52
40. EXAMPLE KNOWLEDGE BASE CONTD.
..
. it is a crime for an American to sell weapons to hostile nations:
American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x)
¬(American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧
Hostile(z) ) ∨ Criminal(x)
¬American(x) ∨ ¬ Weapon(y) ∨ ¬ Sells(x,y,z) ∨ ¬ Hostile(z) )∨ Criminal(x)
Nono … has some missiles, i.e., ∃x Owns(Nono,x) ∧ Missile(x):
Owns(Nono,M1) ∧ Missile(M1)
Owns(Nono,M1) , Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
¬(Missile(x) ∧ Owns(Nono,x) )∨ Sells(West,x,Nono)
¬Missile(x) ∨ ¬ Owns(Nono,x) ∨ Sells(West,x,Nono)
Missiles are weapons:
¬ Missile(x) ∨ Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America) ⇒ Hostile(x)
¬Enemy(x,America) ∨ Hostile(x)
53
54
42. EXAMPLE
1.
8.
1. Marcus was a man.
2.Marcus was a Pompeian.
3.All Pompeians were Romans.
4.Caesar was a ruler.
5.All Pompeians were either loyal to Caesar or
hated him.
6.Every one is loyal to someone.
7.People only try to assassinate rulers they are
not loyal to. Marcus tried to assassinate Caesar.
55
56
6.
7.
48. CHAINING
□To predict outcomes using the given pool of knowledge.
□Knowledge base is given and using logical rules and reasoning, one has
to predict the outcome.
□These problems are usually solved using Inference Engines,
□Utilize their two special modes:
I. Forward Chaining
II. Backward Chaining
63
FORWARD CHAINING
□Step 1: Start from the already stated facts, and then,
subsequently choose the facts that do not have any
implications at all.
□Step 2: Now, those facts that can be inferred from available
facts with satisfied premises.
□Step 3: In step 3, check the given statement that needs to be
checked and check whether it is satisfied with the substitution
which infers all the previously stated facts. Thus we reach our goal.
64
51. BACKWARD CHAINING
□Step 1. In the first step, take the Goal Fact and from
the goal fact, we’ll derive other facts that we’ll prove
true.
□Step 2: derive other facts from goal facts that satisfy
the rules
□Step 3: At step-3, extract further fact which infers
from facts inferred in step 2.
□Step 4: Repeat the same until we get to a certain fact
that satisfies the conditions.
69
70
56. S.no Forward Chaining Backward Chaining
1 Forward chaining starts from
known facts and applies inference
rule to extract more data unit it
reaches to the goal.
Backward chaining starts from the goal and
works backward through inference rules to
find the required facts that support the goal.
2 It is a bottom-up approach It is a top-down approach
3 Forward chaining is known as
data-driven inference technique as
we reach to the goal using the
available data.
Backward chaining is known as goal-driven
technique as we start from the goal and
divide into sub-goal to extract the facts.
4 Forward chaining reasoning
applies a breadth-first search
strategy.
Backward chaining reasoning applies a
depth-first search strategy.
5 Forward chaining tests for all the
available rules
Backward chaining only tests for few
required rules.
6 Forward chaining is suitable for the
planning, monitoring, control, and
interpretation application.
Backward chaining is suitable for diagnostic,
prescription, and debugging application.
7 Forward chaining can generate an
infinite number of possible
conclusions.
Backward chaining generates a finite number
of possible conclusions.
8 Forward chaining is aimed for any
conclusion.
Backward chaining is only aimed for the
required data.
57. LOGIC PROGRAMMING
∙ Logic programming is based on FOPL.
∙ Clause in logic programming is special
form of formula.
∙ Program in logic programming is a collection of
clauses.
∙ Queries are solved using resolution principle.
∙ A clause in logic programming is represented in a
clausal notation as
A1, …, Ak ← B1,…, Bt ,
where Aj are positive literals and Bk are negative literals.
77
78
FOPL
58. LOGIC PROGRAMMING - PROLOG
• Prolog is a declarative programming language based on
logic.
• A Prolog program is a list of facts.
• There are various predicates and functions
• supplied to support I/O, graphics, etc.
• Instead of CNF, prolog uses an implicative
• normal form: A Ù B Ù ... Ù C Þ D
60. PROLOG
:
□Only Horn sentences are acceptable
□The occur-check is omitted from the unification:
unsound
test ← P(x, x) P(x, f(x))
□Backward chaining with depth-first search:
incomplete
P(x, y) ← Q(x, y) P(x, x)
Q(x, y) ← Q(y, x)
81
82
61. Special case: Horn clauses
• Horn clauses are implications with only positive literals
• x1 AND x2 AND x4 => x3 AND x6
• TRUE => x1
• Try to figure out whether some xj is entailed
• Simply follow the implications (modus ponens) as far as you
can, see if you can reach xj
• xj is entailed if and only if it can be reached (can set
everything that is not reached to false)
• Can implement this more efficiently by maintaining, for each
implication, a count of how many of the left-hand side
variables have been reached
62. Ontological Engineering
• What is Ontological Engineering?
Ontology refers to organizing everything in the world (complex
domain) into hierarchy of categories. Representing the abstract
concepts such as Actions,Time,Physical Objects,and Beliefs
with respect to complex domains such as shopping on the
internet or controlling a robot in a changing environment is
called Ontological
63. CATEGORIES AND OBJECTS
The organization of objects into categories is a vital part of
knowledge representation. Although interaction with the world
takes place at the level of individual objects, much reasoning takes
place at the level of categories.
Categories play a role in predictions about objects
• Based on perceived properties
•Categories can be represented in two ways by
• first-order logid (FOL)
• Predicates: apple(x)
• Reification of categories into objects: apples
•Category is considered as set of its
members(Relation=Inheritance).
• For eg: All instance of food are edible, fruit is a subclass
offood and apples is a subclass of fruit then an apple is edible.
•
64. Actions, Situations, and Events
Actions are logical terms such as Forward and Turn (Right). F
now, we will assume that the environment contains only on
agent. (If there is more than one, an additional argument can b
inserted to say which agent is doing the action.)
Situations are logical terms consisting of the initial situation
(usually called So) and all situations that are generated by
applying an action to a situation. The function Result(a, s)
(sometimes called Do) names the situation that results when
action a is executed in situation s. Figure 10.2 illustrates this
idea.
65.
66. Agent can now reason about the beliefs of agents.
Turning a proposition into an object is called reification.
Technically, the property of being able to substitute a term
freely for an equal term is
called referential transparency.
There are two ways to achieve this.
O The first is to use a different form of logic called modal
logic, in which propositional
attitudes such as Believes and Knows become modal operators
that are referentially
opaque. This approach is covered in the historical notes
section.
67. Knowledge and belief
The relation between believing and knowing has been
studied extensively in philosophy. It is commonly
said that knowledge is justified true belief
.Knowledge, time, and action Actions can have
knowledge preconditions and knowledge effects.
Plans to gather and use information are often
represented using a shorthand notation called runtime
variables, Plans to gather and use information are
often represented using a shorthand notation called
runtime variables.
68. Reasoning Systems for Categories
Semantic networks
Visualize knowledge-base
Efficient algorithms for category membership
inference
Description logics
Formal language for constructing and
combining category definitions
Efficient algorithms to decide subset and
superset relationships between categories.
69. Semantic Networks
• Semantic networks are capable of
representing individual objects,categories
of objects,and relation among objects.
Objects or Category names are
represented in ovals and are connected
by labeled arcs.
• Semantic network example
70.
71. Default reasoning
This is a very common form of non-monotonic
reasoning. Here We want to draw conclusions
based on what is most likely to be true.
Non-Monotonic logic.
Default logic
This is basically an extension of first-order predicate
logic to include a modal operator, M. The purpose of this
is to allow for consistency.
For example: : plays_instrument(x) (and) improvises(x)
→ jazz_musician(x)
states that for all x is x plays an instrument and if the fact
that x can improvise is consistent with all other knowledge
then we can conclude that x is a jazz musician.
72. Truth Maintenance Systems
(TMS)
Many inferences have default status rather
than being absolutely certain.
• Inferred facts can be wrong and need to
be retracted (new info) and it is called as
belief revision.
73. Types of TMS
1)Justification-Based Truth Maintenance Systems (JTMS)
▪This is a simple TMS in that it does not know anything about
the structure of the assertions themselves.
▪Each supported belief (assertion) in has a justification.
▪Each justification has two parts:
An IN-List -- which supports beliefs held.
An OUT-List -- which supports beliefs not held.
▪An assertion is connected to its justification by an arrow.One
assertion can
feed another justification thus creating the network.Assertions may
be labelled with a belief status.
75. 2)Logic-Based Truth Maintenance Systems (LTMS)
Similar to JTMS except:
Nodes (assertions) assume no relationships among them except ones
explicitly stated in justifications.
JTMS can represent P and ¬P simultaneously. An LTMS would throw a
contradiction here.
If this happens network has to be reconstructed.
3)Assumption-Based Truth Maintenance Systems (ATMS)
JTMS and LTMS pursue a single line of reasoning at a time and backtrack
(dependency- directed) when needed -- depth first search.
ATMS maintain alternative paths in parallel -- breadth-first search
Backtracking is avoided at the expense of maintaining multiple contexts.