Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
KNOWLEDGE REPRESENTATION
OUTLINE
KNOWLEDGE……….
• The facts are claims about the world that are True or False.
• Logic can be used to represent simple facts.
• To build a Logic-based representation :
◊ User defines a set of primitive symbols and the associated semantics.
◊ Logic defines ways of putting symbols together so that user can define
legal sentences in the language that represent TRUE facts.
◊ Logic defines ways of inferring new sentences from existing ones.
◊ Sentences - either TRUE or false but not both are called propositions.
PROPOSITIONAL LOGIC
Examples: (a) The sky is blue., (b) Snow is cold. , (c) 12 * 12=144
Consider example :
" All men are mortal.
Socrates is a man.
Then Socrates is mortal" ,
These cannot be expressed in propositional logic as a finite and logically
valid argument (formula).
Example :
A sentence "Judy (runs)".
Predicate is a verb phrase template that describes a property of objects, or a relation among objects
represented by the variables.
FOPL ………………
Example:
Predicates are given names; Let 'B' is name for predicate "is_blue".
Consider the expression with the respective logic symbols || and &&
--Entities can be set of real numbers, set of integers, sets of all cars on a
parking lot, the set of all students in class room etc.
An atomic formula (or simply atom) is a formula with no deeper propositional structure, i.e.,
a formula that contains no logical connectives or a formula that has no strict sub-formulas.
Compound formulas are formed by combining the atomic formulas using the logical
connectives.
Well-formed formula (“WFF") is a symbol or string of symbols (a formula) generated by the formal
grammar of a formal language.
FIRST-ORDER LOGIC
• Relations: red, round, prime, brother of, bigger than, part of, comes between, …
• Constant Symbols:
• Stand for objects
• e.g., KingJohn, 2, UCI,...
• Predicate Symbols
• Stand for relations
• E.g., Brother(Richard, John), greater_than(3,2)...
• Function Symbols
• Stand for functions
• E.g., Sqrt(3), LeftLegOf(John),...
SYNTAX OF FOL: BASIC ELEMENTS
• Variables x, y, a, b,...
• Equality =
Registration
RA
s-id c.id Grade Satisfaction
s-id p-id Salary Capability Jack 101 A 1
Jack Oliver High 3 Jack 102 B 2
Kim Oliver Low 1 Kim 102 A 1
Paul Jim Med 2 Paul 101 B 1
TERMS
• Examples:
LargerThan(2,3) is false.
Brother_of(Mary,Pete) is false.
Married(Father(Richard), Mother(John)) could be true or false
COMPLEX SENTENCES
binary function
relation
objects
connectives
MORE EXAMPLES
• King(Richard) King(John)
• We can be much more flexible if we allow variables which can take on values
in a domain. e.g., all persons x, all integers i, etc.
• E.g., can state rules like Person(x) => HasHead(x)
or Integer(i) => Integer(plus(i,1)
UNIVERSAL QUANTIFICATION
• means “for all”
• Allows us to make statements about all objects that have certain properties
• Can now state general rules:
x King(x) => Person(x)
Note that
x King(x) Person(x) is not correct!
This would imply that all objects x are Kings and are People
x King(x) => Person(x) is the correct way to say
EXISTENTIAL QUANTIFICATION
• x means “there exists an x such that….” (at least one object x)
• Allows us to make statements about some object without naming it
• Examples:
x King(x)
x Lives_in(John, Castle(x))
i Integer(i) GreaterThan(i,0)
x y Loves(x,y)
• For everyone (“all x”) there is someone (“y”) that they love.
y x Loves(x,y)
- there is someone (“y”) who is loved by everyone
In effect:
- is a conjunction over the universe of objects
- is a disjunction over the universe of objects
Thus, DeMorgan’s rules can be applied
DE MORGAN’S LAW FOR QUANTIFIERS
• First-order logic:
• Much more expressive than propositional logic
• Allows objects and relations as semantic primitives
• Universal and existential quantifiers
• syntax: constants, functions, predicates, equality,
quantifiers
• Knowledge engineering using FOL
• Capturing domain knowledge in logical form
CHAINING STRATEGIES……………
The search control strategies are of different types, and are realized
by some specific type of "Control Structures".
◊ Activation of Rules
The Forward chaining and Backward chaining are the two different
strategies for activation of rules in the system.
Forward and Backward chaining are some techniques for drawing
inferences from Rule base.
FORWARD CHAINING…..
Rule 3: If B Then E
Rule 4: If G Then D
■ Problem : Prove that
Second iteration :
‡ Rule 2 fires : conclusion G is true
‡ new knowledge found
‡ Rule 4 fires : conclusion D is true
‡ Goal found;
‡ Proved
BACKWARD CHAINING
◊ The algorithm proceeds from desired goal, adding new assertions (facts)
found.
Rule 3: If B Then E
Rule 4: If G Then D
◊ Problem : Prove
If A and B true Then D is true
BACKWARD
• Unification: The process of finding all legal substitutions that make logical expressions
look identical
UNIFICATION
• We can get the inference immediately if we can find a substitution θ such that King(x)
and Greedy(x) match King(John) and Greedy(y)
• θ = {x/John, y/John} works
• Unify(a,b) = θ if a θ = b θ
UNIFICATION
RESOLUTION…..
59
CONVERTING TO CNF
1. Replace implication (A B) by A B
2. Move “inwards”
• x P(x) is equivalent to x P(x) & vice versa
3. Standardize variables
• x P(x) x Q(x) becomes x P(x) y Q(y)
4. Skolemize
• x P(x) becomes P(A)
5. Drop universal quantifiers
• Since all quantifiers are now , we don’t need them
6. Distributive Law
60
CONVERT TO FOPL, THEN CNF
• Ontology is defined as a set of concepts and categories in a subject area or domain that
shows their properties and the relations between them.
• Ontological Engineering studies the methods and methodologies for building ontologies.
Limitations of logic representation
• Inability to represent exceptions and uncertainty
Ontological Engineering studies………….
Relation = inheritance:
– All instance of food are edible, fruit
is a subclass of food and apples is a
subclass of fruit then an apple is
edible.
Defines a taxonomy
FOL AND CATEGORIES
An object is a member of a category
– MemberOf(BB12,Basketballs)
A category is a subclass of another category
– SubsetOf(Basketballs,Balls)
All members of a category have some properties
– x (MemberOf(x,Basketballs) Round(x))
All members of a category can be recognized by some properties
– x (Orange(x) Round(x) Diameter(x)=9.5in
MemberOf(x,Balls) MemberOf(x,BasketBalls))
A category as a whole has some properties
– MemberOf(Dogs,DomesticatedSpecies)
RELATIONS BETWEEN CATEGORIES
Two or more categories are disjoint if they have no members in common:
– Disjoint(s)( c1,c2 c1 s c2 s c1 ¹ c2 Intersection(c1,c2)
={})
– Example; Disjoint({animals, vegetables})
A set of categories s constitutes an exhaustive decomposition of a category c if
all members of the set c are covered by categories in s:
– E.D.(s,c) ( i i c c2 c2 s i c2)
– Example: ExhaustiveDecomposition({Americans, Canadian,
Mexicans},NorthAmericans).
RELATIONS BETWEEN CATEGORIES
A partition is a disjoint exhaustive decomposition:
– Partition(s,c) Disjoint(s) E.D.(s,c)
– Example: Partition({Males,Females},Persons)
Situation calculus:
Actions are logical terms
Situations are logical terms
consiting of
The initial situation I
All situations resulting
from the action on I
(=Result(a,s))
Fluent are functions and
predicates that vary from one
situation to the next.
E.g. Holding(G1, S0)
Eternal predicates are also
allowed
E.g. Gold(G1)
ACTIONS, EVENTS AND SITUATIONS
• Results of action
sequences are determined
by the individual actions.
• Projection task: an SC
agent should be able to
deduce the outcome of a
sequence of actions.
• Planning task: find a
sequence that achieves a
desirable effect
ACTIONS, EVENTS AND SITUATIONS
DESCRIBING CHANGE
• Simple Situation calculus requires two axioms to describe change:
• Possibility axiom: when is it possible to do the action
At(Agent,x,s) Adjacent(x,y) Poss(Go(x,y),s)
• Effect axiom: describe changes due to action
Poss(Go(x,y),s) At(Agent,y,Result(Go(x,y),s))
• What stays the same?
• Frame problem: how to represent all things that stay the same?
• Frame axiom: describe non-changes due to actions
At(o,x,s) (o Agent) Holding(o,s) At(o,x,Result(Go(y,z),s))
REPRESENTATIONAL FRAME PROBLEM
• If there are F fluents and A actions then we need AF frame axioms to
describe other objects are stationary unless they are held.
• We write down the effect of each actions
• Solution; describe how each fluent changes over time
• Successor-state axiom:
Pos(a,s) (At(Agent,y,Result(a,s)) (a = Go(x,y))
(At(Agent,y,s) a Go(y,z))
• Note that next state is completely specified by current state.
• Each action effect is mentioned only once.
OTHER PROBLEMS
• How to deal with secondary (implicit) effects?
• If the agent is carrying the gold and the agent moves then the gold
moves too.
• Ramification problem
• How to decide EFFICIENTLY whether fluents hold in the future?
• Inferential frame problem.
• Extensions:
• Event calculus (when actions have a duration)
• Process categories
MENTAL EVENTS AND OBJECTS
• So far, KB agents can have beliefs and deduce new beliefs
• What about knowledge about beliefs? What about knowledge about the
inference process?
• Requires a model of the mental objects in someone’s head and the
processes that manipulate these objects.
• Relationships between agents and mental objects: believes, knows, wants,
…
• Believes(Lois,Flies(Superman)) with Flies(Superman) being a function
… a candidate for a mental object (reification).
• Agent can now reason about the beliefs of agents.
THE INTERNET SHOPPING WORLD
• A Knowledge Engineering example
• An agent that helps a buyer to find product offers on the internet.
• IN = product description (precise or precise)
• OUT = list of webpages that offer the product for sale.
• Environment = WWW
• Percepts = web pages (character strings)
• Extracting useful information required.
THE INTERNET SHOPPING WORLD
• Find relevant product offers
RelevantOffer(page,url,query) Relevant(page, url, query) Offer(page)
• Write axioms to define Offer(x)
• Find relevant pages: Relevant(x,y,z) ?
• Start from an initial set of stores.
• What is a relevant category?
• What are relevant connected pages?
• Require rich category vocabulary.
• Synonymy and ambiguity
• How to retrieve pages: GetPage(url)?
• Procedural attachment
• Compare offers (information extraction).
REASONING SYSTEMS FOR CATEGORIES
• How to organise and reason with 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.
SEMANTIC NETWORKS
• Logic vs. semantic networks
• Many variations
• All represent individual objects, categories of objects and relationships
among objects.
• Allows for inheritance reasoning
• Female persons inherit all properties from person.
• Cfr. OO programming.
• Inference of inverse links
• SisterOf vs. HasSister
SEMANTIC NETWORK EXAMPLE
SEMANTIC NETWORKS
• Drawbacks
• Links can only assert binary relations
• Can be resolved by reification of the proposition as an event
• Representation of default values
• Enforced by the inheritance mechanism.
DESCRIPTION LOGICS