Sie sind auf Seite 1von 39

Knowledge

Representation
What is Logic?
 Logic: the set of patterns used to carry out
reasoning.
 It is a language used to represent facts.
 Pattern: a template or a set of rules found as a
result of observing commonalities.

 Reasoning: is the act of using reason.

 Reason: ability of the human mind to form


concepts or knowledge and operate on symbols
or language.
Knowledge Representation
Methodologies
 Logic is used for designing of
Knowledge base.

 Methodologies
 Representation in Propositional logic.
 Representation in Predicate logic.
 Representation through Semantic net.
 Representation using Conceptual
Dependency structures.
 Representation using Frames.
Types of Logic
Theories of Logic What Exists Belief of Agents
Propositional Logic Facts T/F
First Order
Predicate Logic Facts, objects, T/F
or simply relations
Predicate Logic
Temporal Logic Facts, object, T/F
Relations, Times
Probability theory Facts Degree of belief
[0…..1]
Fuzzy Logic Degree of truth Degree of belief
[0…..1]
Propositional Logic
Propositional Logic also
called Sentential Logic
 The study of statements and their
connectivity structure.
 includes sentence letters (A,B,C) and
logical connectives, but not quantifiers.
 Propositional logic is declarative.
E.g.. It is raining.
 Propositional logic has very limited
expressive power.
Proposition Logic: Syntax
 Atomic Sentence: true, false, variable
 Complex Sentence: connective applied to atomic or complex
sentence.
 Connectives: NOT, AND, OR, IMPLIES, EQUIVALENCE, etc.
 Sentences are combined by connectives:
and [conjunction]
 or [disjunction]
 implies [implication / conditional]
 is equivalent [bi-conditional]
 not [negation]
 Well formed formulae (WFF) consists of atomic symbols joined
with connectives.

WFF is a syntactic object that can be given a semantic meaning.


Propositional Logic:
Semantics
 Truth tables:
p q p =>q ~p or q
t t t t
t f f f
f t t t
f f t t
Translation into Propositional
Logic

 If it rains, then the game will be cancelled.


 If the game is cancelled, then we clean house.
 Can we conclude?
 If it rains, then we clean house.
 p = it rains, q = game cancelled, r = we clean
house.
If p then q. not p or q
If q then r. not q or r
If p then r. not p or r (resolution)
Translation into Propositional Logic

Representing simple facts


It is raining
RAINING
It is sunny
SUNNY
It is windy
WINDY
If it is raining, then it is not sunny
RAINING   SUNNY
Example of Propositional Logic
sentences

 P : It is NOT cloudy.
 Q : It is NOT raining.
 PQ : It is cloudy OR it is raining.
 PQ : It is cloudy AND it is raining.
 PQ : It is cloudy indicates, it is raining.
 PQ : It is cloudy indicates that it is
raining and it is raining indicates
that it is cloudy.
NORMAL FORMS
Normal Forms
 To transform formulas into standard forms so
that they become more convenient for symbolic
manipulations and make identification and
comparison of two formulas easier, normal
forms are used.
 There are two types of normal forms in
propositional calculus:
 The Conjunctive Normal Form.
 The Disjunctive Normal Form.
Types of Normal Forms

Conjunctive Normal Form


Formula A is said to be in CNF if it has the form
A= A1 & A2 & A3…………………………….& An, n>=1
Where each A1, A2, A3……….An is a disjunction of an atom
or negation of an atom

Disjunctive Normal Form


Formula A is said to be in DNF if it has the form
A= A1 V A2 V A3…………………………….V An, n>=1
Where each A1, A2, A3……….An is a conjunction of an atom or
negation of an atom
Conversion Procedure to Normal Form

Step 1: Eliminate implication and bi-implication


(A→B) = ~A V B
(A↔B) = (A→B) & (B→A)
= (~A V B) & (~B V A)
Step 2: Reduce the scope of NOT symbol
~(A V B) = ~A & ~B
~(A & B) = ~A V ~B
Step 3: Use Distributive laws and other equivalent formulae
A & (B V C)=(A & B) V (A & C)
A V (B & C)=(A V B) & (A V C)
 Convert the formula ((A → B) → C) into CNF
 Convert the formula (A →((B & C) →D)) into DNF
Convert the formula ((A → B) → C) into CNF

Step 1: Eliminate Implication


~(A → B) V C = ~(~A V B) V C

Step 2: Reduce the scope of Not Operator


= (A & ~B) V C

Step 3: Use Distributive law


= (A V C) & (~B V C)
Hence (A V C) & (~B V C) is the CNF of ((A → B)→C)
Convert the formula (A →((B & C) →D)) into DNF

Step 1: Eliminate Implication


= ~A V (( B & C) → D)
= ~A V(~( B & C) V D)
Step 2: Reduce the scope of NOT Symbol
= ~A V ~B V ~C V D
PREDICATE LOGIC
Predicate Logic

 Logic which is concerned not only with


sentential connectives but also with the
internal structure of atomic propositions
is usually called a predicate logic.

 Two common quantifiers are the


existential  and universal  quantifiers.
First Order Predicate Logic
 First-order predicate logic (like natural
language) assumes the world contains:
 Objects: people, houses, numbers,
colors, baseball games, wars, …
 Relations: prime, brother of, bigger than,
part of, comes between, …
 Functions: father of, best friend, one
more than, plus, …   
Syntax of FOPL: Basic elements
 Constants a, b, c, Ram, 2, ...
 Predicates P, Q, R, EQUAL, ...
 Functions Sqrt, f, g, h, father-of, …
 Variables x, y, z, ...
 Connectives (Not), (Implies),
(And(conjuction)), (Or(disjunction)),
(Double implies)
 Equality =
 Quantifiers , 
Using First Order Predicate Logic
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.
8. Marcus tried to assassinate Caesar.
Using First Order Predicate Logic
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.
x: Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)
Using First Order Predicate Logic
6. Every one is loyal to someone.
x: y: loyalto(x, y)
7. People only try to assassinate rulers they are not loyal to.
x: y: person(x)  ruler(y)  tryassassinate(x, y)
 loyalto(x, y)
8. Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)
E(x) for x is an employee.
P(x) for x is president.
i(x) for the income of x.
GE(u,v) for u is greater than or equal to v.
S(x) for x is sick today.
T(x) for x pays taxes.

1. All employees earning Rs. 3lacs or more per year


pay taxes.
x: E(x)  GE(i(x),3lacs))  T(x)
2. Some employees are sick today.
x: E(x)  S(x)

3. No employee earns more than the president.


xy: E(x)  P(y)   GE (i(x), i(y))
1. All dogs are mammals
x: dogs(x)  mammal(x)
2. None of my programs have bugs.
x: program(x)  created_by(x, me)   have _bugs(x)
3. All coats in the cupboard belong to Reena.
x: coat(x)  cupboard(y)  in(x,y)  belongs (x,Reena)
4. One of the coats in the cupboard belongs to Sarah.

x: coat(x)  cupboard(y)  in(x,y)  belongs (x,Sarah)


Conversion to Clause Form
Conversion to Clause Form
 Problem:
x: [Roman(x) know(x,Marcus)] [hate(x,Caesar) V
(y:z: hate(y,z)  thinkcrazy(x,y))]
 Solution:
 Flatten
 Separate out quantifiers
 Conjunctive Normal Form:
Roman(x) v know(x,Marcus) v hate(x,Caesar) v
 hate(y,z) v thinkcrazy(x,z)
 Clause Form
 Conjunctive normal form
 No instances of 
Algorithm: Conversion to Clause Form

1. Eliminate , using: a  b=  a v b.
2. Reduce the scope of each  to a single term, using:
 ( p) = p
deMorgan's laws: (a  b) =  a V  b
(a V b) =  a   b
 x P(x) = x  P(x)
 x P(x) = x  P(x)

3. Standardize variables.
4. Move all quantifiers to the left of the formula without changing their
relative order.
5. Eliminate existential quantifiers by inserting Skolem functions.
6. Drop the prefix.
7. Convert the expression into a conjunction of disjuncts, using
associativity and distributivity.
8. Create a separate clause for each conjunct.
9. Standardize apart the variables in the set of clauses generated in
step 8, using the fact that: (x : P(x)  Q(x)) = x : P(x)  x : Q(x)
Algorithm: Conversion to Clause Form
Skolem Functions in FOPL
 Objective (removing existential quantifiers from logic statements)
 Want all variables universally quantified
 Notational variant of FOL wff existentials
 Retain implicitly full FOL expressiveness
 Skolem’s Theorem
Every existentially quantified variable can be replaced by a unique
Skolem function whose arguments are all the universally quantified
variables on which the existential depends, without changing FOL.
 Examples
 “Everybody likes something”
(x)  (y) [Person(x) & Likes(x,y)]
(x) [Person(x) & Likes(x, S1(x))]
Where S1(x) = “that which x likes”
 “Every philosopher writes at least one book”
(x) (y)[Philosopher(x) & Book(y)) => Write(x,y)]
(x)[(Philosopher(x) & Book(S2(x))) => Write(x,S2(x))]
Example of Conversion to
Clause Form
Example:
x: [Roman(x)  know(x, Marcus)] [hate(x,Caesar) V (y:
z: hate(y,z)  thinkcrazy(x,y))]
Eliminate 
x: [Roman(x)  know(x, Marcus)] V [hate(x,Caesar) V
(y:z: hate(y,z) V thinkcrazy(x,y))]
Reduce the scope of each  to a single term.
x: [ Roman(x) V  know(x, Marcus)] V [hate(x,Caesar) V
(y: z: hate(y,z) V thinkcrazy(x,y))]

Standardize variables so that each quantifier binds a


unique variable:
x: P(x) V x: Q(x) converts to x: P(x) V y: Q(y)
Example of Conversion to
Clause Form
 Move quantifiers
x: y: z: [Roman(x) V  know(x, Marcus)] V
[hate(x,Caesar) V (hate(y,z) V thinkcrazy(x,y))]
 Eliminate existential quantifiers.
y: President(y) will be converted to President(S1)
x: y: father-of(y,x) will be converted to
x: father-of(S2(x),x))
 Drop the prefix.
[ Roman(x) V  know(x,Marcus)] V [hate(x,
Caesar) V ( hate(y,z) V thinkcrazy(x,y))]

 Convert to a conjunction of disjuncts.


 Roman(x) V  know(x,Marcus) V hate(x,Caesar) V
 hate(y,z) V thinkcrazy(x,y)
Resolution
The Basis of Resolution

 Given:
winter V summer
 winter V cold

We can conclude:
summer v cold
Resolution Principle
 Resolution procedure is a simple iterative process; at
each step, two clauses called the parent clauses, are
resolved into a new clause that has been inferred
from them.
 E.g
winter  summer
winter  cold

 Summer  cold
A Resolution Proof
 Axioms in clause form:
1. man(Marcus)
2. Pompeian(Marcus)
3.  Pompeian(x1) v Roman(x1)
4. Ruler(Caesar)
5.  Roman(x2) v loyalto(x2, Caesar) v hate(x2,Caesar)
6. loyalto(x3, f1(x3))
7.  man(x4) v  ruler(y1) v  tryassassinate(x4, y1) v
 loyalto (x4, y1)
8. tryassassinate(Marcus, Caesar)
Resolution Proof cont.
To Prove: hate(Marcus, Caesar) hate(Marcus, Caesar) 5

Marcus/x2
3 Roman(Marcus) V loyalto(Marcus,Caesar)

Marcus/x1
Pompeian(Marcus) V loyalto(Marcus,Caesar) 2

7 loyalto(Marcus,Caesar)

Marcus/x4, Caesar/y1

1 man(Marcus) V  ruler(Caesar) V  tryassassinate(Marcus, Caesar)

 ruler(Caesar) V  tryassassinate(Marcus, Caesar) 4

 tryassassinate(Marcus, Caesar) 8
Issues with Resolution
 Requires full formal representation in FOL (for
conversion to clause form)

 Resolution defines a search space (which clauses will be


resolved against which others define the operators in
the space)  search method required

 Worst case: resolution is exponential in the number of


clauses to resolve. Actual: exponential in average
resolvable set (= branching factor)
धन्यवाद

Das könnte Ihnen auch gefallen