2. knowldege representation
DESCRIPTION
Artificial intelligenceTRANSCRIPT
Chapter 2
Knowledge Representation
2
Methods of Knowledge Representation
• Propositional Logic• Predicate Logic• Semantic Networks• Frames• Fuzzy Logic
3
Propositional Logic Proposition is a statement that is either TrueTrue or or FalseFalse
Propositional logic is the simplest method of reasoning, which represents
knowledge, allowing automated inference and problem solving.
Concepts are translated into symbolic representations (P, Q, R, S, etc.)
which closely approximate the meaning of the facts, to carry out a form of
automated reasoning.
Symbols represent whole propositions (facts).
Symbols are joined by logical connectives (and, or, implication);
e.g., P Q; Q R
Examples: TrueFalse
2 + 2 = 43 x 3 = 8
4
Propositional Logic…In propositional logic, a world is represented as knowledge using a list of facts.
– Propositional connectives and their truth tables• Negation: ~P• Conjunction: P ۸ Q • Disjunction: P ۷ Q (inclusive or)• Implication: P Q • Equivalence: P Q
– Other propositional connectives• PQ (exclusive or), PQ (nor), PQ (nand),..
5
Propositional Logic…Syntax of PL
Symbol: P | Q | R | S | ... atomic sentence: TRUE | FALSE Sentence: atomic sentence | complex sentence complex sentences: ~ sentence | (sentence ^ sentence) | (sentence v
sentence) | (sentence sentence) |
(sentence sentence)
Precedence relation operators: ~,^,v,, .
6
Propositional Logic: Examples My car is painted red. Snow is white. People live on the moon.
Logical connectives: It is raining and the wind is blowing. I shall go there or ask Kamal to visit him. If you study heard you will be successful. The sum of 20 and 30 is not 100. The car belongs to the Chairman is painted silver.
Semantic Rules for Statements
7
TT F Fa a T T44 F or F’ F or F’ T or T’T or T’55
F & aF & aT or aT or a33~ T~ T~ F~ F22FFTT11False Statements
True Statements
Rule No.
8
Properties of StatementsValid: A statement is valid if it is true for every interpretations. Valid statements are also called tautologies.
Satisfiable: A statement is satisfiable if there is some interpretation for which it is true.
Contradiction: A statement is said to be contradictory (unsatisfiable) if there is no interpretation for which it is true.
Equivalence: Two sentences are equivalent if they have the same truth value under every interpretation.
Semantics & Interpretations
9
ttfftttttttt
ffffttfffftt
ttttttffttff
ttttffffffff(~P Q)P Q~ PP QP QQP
10
Meaning of StatementsWhat would be the meaning of the following statement, if some interpretation imply true to P, false to Q and false to R ?: ((P & ~ Q) R) Q Assignments:1. Find the meaning of the statement:(~ P V Q) & R S V (~ R & Q)for each of the interpretations given below:I1: P is true, Q is true, R is false, S is true.I2: P is true, Q is false, R is true, S is true.2. Determine whether each of the following sentence is (a) satisfiable (b) contradictory, or (c) valid S1: (P & Q) V ~ (P & Q) S2: (P V Q) (P & Q)S3: (P & Q) R V~Q S4: (P V Q) & (P V ~Q) V P
S5: P Q ~P S6: P V Q & ~P V ~Q & P
Meaning of Statements… If it rains heavily then it causes flood. Flood brings miserable
impacts on our daily life, if the government fails to take necessary steps. Luckily, we don’t have any awful situation this year. So, flood didn’t occur this year or the government took appropriate steps.
P : It rains heavily Q : It causes flood
S : Miserable impacts G : Government activities
((P Q) (~G (Q S)) ~S) (~Q G )
P Q S G
11
Rules of InferenceRules of Inference Modus Ponens: P Q => {((P Q) P) Q} P Q Modus Tollens P Q {((P Q) ~ Q) ~ P}
~ Q ~ P Hypothetical Syllogism (H. S.) (P Q) & (Q R)
P R Disjunctive Syllogism (D. S.) (P V Q) ~ P
Q 12
Drawbacks of PL
13
Propositional logic isn’t powerful enough as a general knowledge representation language.
Impossible to make general statements. E.g., “all students sit exams” or “if any student sits an exam
they either pass or fail”. So we need predicate logic..
14
Predicate Logic In predicate logic the basic unit is a predicate/argument structure
called an atomic sentence:– LIKES (azad, chocolate)– TALL (habib)
Arguments can be any of:– constant symbol, such as ‘azad’– variable symbol, such as x– function expression, e.g., FATHER_OF (hasan)
So we can have:– LIKES (X, chocolate)– FRIENDS (FATHER_OF (rita), FATHER_OF (choiti))
15
Syntax of Predicate Logic These atomic sentences can be combined
using logic connectives– LIKES (rita, hasan) TALL (hasan)– BASKET_BALL_PLAYER (hasan) – TALL (hasan)
Sentences can also be formed using quantifiers– x LOVELY (x) Everything is lovely.– x LOVELY (x) Something is lovely. x IN (x, garden) LOVELY (x) Everything in
the garden is lovely.
16
Predicate Logic: Examples ... All employees earning TK. 30,000 or more per
year pay taxes. x ((E(x) & GE (i (x), 30000)) T(x) Some employees are sick today y E(y) S(y) No employee earns more than the president x y ((E(x) & P(y)) ~GE((i (x), i (y))
17
Examples of Predicate Logic Can have several quantifiers, e.g.,
x y LOVES (x, y)
So we can represent things like:– All men are mortal.– No one likes hartal.– Everyone taking AI will pass their exams.– Every race has a winner.– Sajjad likes everyone who is tall.– Rita doesn’t like anyone who prefers arguments.
(Assignment/Home work)
18
Rules of Predicate Logic
There is a precise meaning to expressions in predicate logic.
Like in propositional logic, it is all about determining whether something is true or false.
x P(x) means that P(x) must be true for every object x in the domain of interest.
x P(x) means that P(x) must be true for at least one object x in the domain of interest.
Knowledge is expressed as a collection of concepts, represented by nodes (shown as boxes in the diagram), connected together by relationships, represented by arcs (shown as arrows in the diagram).
certain arcs - particularly isa arcs - allow inheritance of properties.
19
Semantic Net An long existing notion: there are different pieces of
knowledge of world, and they are all linked together through certain semantics.
Nodes– Represent concepts
Arcs– Represent relations
Labels – for nodes and arcs
Basic ComponentsBasic Components
hasan
student
21 rita
IS-A
FRIEND-OFAGE
20
Semantic Net Common arcs used for representing hierarchies include isa and
has-part.Example: The Queen Mary is an ocean liner. Every ocean liner is a ship.
ship
Ocean_liner
Queen_mary
IS_A
IS_A
21
Semantic Networks Knowledge is represented as a network or graph
animal
reptile
elephant
Nellie
mammal
apples
large
head
HAS_PART
is-a_subclass
instance
LIKES
SIZEafricaLIVES_IN
is-a_subclass is-a_subclass
22
Major Limitations: Semantic net Lack of Semantics
– No formal semantic of the relations E.g. Does “ISA” mean subclass, member, etc?
– Possible multiple interpretations– Restricted expressiveness
E.g. can not distinguish between instance and classAdvantages:
Easy to follow hierarchy, easy to trace association, flexible
Disadvantages: Meaning attached to nodes might be ambiguous exception handling is difficult difficult to program
23
Frames Devised by Marvin Minsky, 1975. Incorporates certain valuable human thinking
characteristics:– Expectations, assumptions, stereotypes.
Exceptions. Fuzzy boundaries between classes.
A data structure for representing a stereotyped situation
A network of nodes and relations organized in a hierarchy
the topmost nodes - general concepts the lower nodes - more specific instances The idea of frame hierarchies is very similar to the idea
of class hierarchies found in object-orientated programming.
24
How Frames are Organized A frame system is a hierarchy of frames Each frame has:
– a name.– slots: these are the properties of the entity
that has the name, and they have values. A particular value may be:
a default value an inherited value from a higher frame a procedure, called a demon, to find a value
In the higher levels of the frame hierarchy, typical knowledge about the class is stored. – The value in a slot may be a range or a condition.
In the lower levels, the value in a slot may be a specific value, to overwrite the value which would otherwise be inherited from a higher frame.
25
Frames …
((hasanhasan (NAME (value hasan shahriar))(NAME (value hasan shahriar)) (AGE (value 25))(AGE (value 25)) (PROFESSION (value student))(PROFESSION (value student)) (ADDRESS (Road (value 30 college (ADDRESS (Road (value 30 college
street))street)) (Thana (value savar))(Thana (value savar)) (District (value dhaka))))(District (value dhaka))))
26
Frames …
– Advantages: Expressive power, easy to set up slots for
new properties and relations easy to create specialized procedures easy to include default information and
detect missing values– Disadvantages:
Difficult to program difficult for inference
27
Summary Predicate logic provides well defined language for
knowledge representation supporting inference. Semantic nets, frames and objects all allow you to
define relations between objects, including class relations (X isa Y).
Only restricted inference supported by the methods - that based on inheritance.
So.. Jimy is a dog, dogs have 4 legs, so Jimy has 4 legs.
Frames/Networks/Objects more natural, but only explicitly support inheritance, and may not have well defined semantics.
Current trend is either to just use OO, or to use logic, but specialises non-logic-based languages still exist.
Thank you for enjoying the Thank you for enjoying the class.class.