02 Formal Logic KR
02 Formal Logic KR
02 Formal Logic KR
KNOWLEGE
REPRESENTATION
Prof.Dr.Ir.Sudjati Rachmat,DEA
1
A Knowledge-Based Agent
• A knowledge-based agent consists of a knowledge base (KB) and an
inference engine (IE).
• A knowledge-base is a set of representations of what one knows
about the world (objects and classes of objects, the fact about objects,
relationships among objects, etc.)
• Each individual representation is called a sentence.
• The sentences are expressed in a knowledge representation
language.
• Examples of sentences
– The moon is made of green cheese
– If A is true then B is true
– A is false
– All humans are mortal
– Confucius is a human
• The Inference engine derives new sentences from the input and
KB
• The inference mechanism depends on representation in KB
• The agent operates as follows:
1. It receives percepts from environment
2. It computes what action it should perform (by IE and KB)
3. It performs the chosen action (some actions are simply
inserting inferred new facts into KB).
S := <Sentence> ;
<Sentence> := <AtomicSentence> | <ComplexSentence> ;
<AtomicSentence> := "T" | "F" |
"P" | "Q" | "S" ;
<ComplexSentence> := "(" <Sentence> ")" |
<Sentence> <Connective> <Sentence> |
~<Sentence> ;
<Connective> := | | => | <=> ;
<literal> := <AtomicSentence> | ~ <AtomicSentence>
Examples of PL sentences
• P means "It is hot"
• Q means "It is humid"
• R means "It is raining"
• 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."
Propositional Logic (PL): Semantics
• Need an interpretation of symbols for a given set of sentences
– Proposition symbols do not have meaning by themselves
– An interpretation connects proposition symbols to a statement
about the world (which may be true or false in that world)
– An interpretation in PL can be defined as an assignment of truth
values to all proposition symbols involved
– There are many interpretations for a given set of sentences (2^n if
they involve n distinct proposition symbols)
– Example:
I_1: P: it is humid (T) Q: it is hot (T) P ^ Q is true
I_2: P: moon is made of green cheese (F)
Q: I am happy (T) P ^ Q is false
• Give a meaning to each logical connectives
– A connective is a function (boolean),
– It does not depend on any particular interpretations (universal to
all PL sentences
– It can best be defined by a truth table
• Truth value of each sentence can then calculated
~Q v R
theorem
R
• Theorem proving as search
– Start node: the set of given premises/axioms (KB + Input)
– Operator: inference rule (add a new sentence into parent node)
– Goal: a state that contains the theorem asked to prove
– Solution: a path from start node to a goal
Normal forms of PL sentences
• Disjunctive normal form (DNF)
– Any sentence can be written as a disjunction of conjunctions of
literals.
– Examples: P ^ Q ^ ~R; A^B v C^D v P^Q^R; P
– Widely used in logical circuit design (simplification)
• Conjunctive normal form (CNF)
– Any sentence can be written as a conjunction of disjunctions of
literals.
– Examples: P v Q v ~R; (A v B) ^ (C v D) ^ (P v Q v R); P
• Normal forms can be obtained by applying equivalence
laws
[(A v B) => (C v D)] => P
~[~(A v B) v (C v D)] v P
[~~(A v B) ^ ~(C v D)] v P
[(A v B)^(~C ^ ~D)] v P
(A v B v P)^(~C^~D v P)
(A v B v P)^(~C v P)^(~D v P) a CNF
Horn Sentences
• A Horn sentences is a disjunction of literals with at most one of
these literals being non-negated (positive).
~P1 v ~P2 v ~P3 ... v ~Pn v Q; or alternatively
P1 ^ P2 ^ P3 ... ^ Pn => Q; (an implication or if-then rule)
• Some properties of Horn sentences
– P => Q ^ R (P => Q) ^ (P => R)
– P v Q => R (P => R) ^ (Q => R)
– P => Q v R cannot be represented as Horn sentences
• We will expand Horn sentences to Horn clauses in first order
predicate logic later and give it more discussion then
• As we will see later, Horn clauses make automating logical
inference easier.
PL is Too Weak a Representational Language