Notes 8: Predicate logic and inference
description
Transcript of Notes 8: Predicate logic and inference
Notes 8:Predicate logic and inference
ICS 270a Spring 2003
Outline
New ontology objects,relations,properties,functions.
New Syntax Constants, predicates,properties,functions
New semantics meaning of new syntax
Inference rules for Predicate Logic (FOL) Resolution Forward-chaining, Backword-chaining unification
Readings: Nillson’s Chapters 15-16, Russel and Norvig Chapter 8, chapter 9
Propositional logic is not expressive Needs to refer to objects in the world, Needs to express general rules
On(x,y) ~ clear(y) All man are mortal Everyone who passed age 21 can drink One student in this class got perfect score Etc….
First order logic, also called Predicate calculus allows more expressiveness
Syntax
Components Infinite set of object constants, alphanumerc strings
Bb, 12345, Jerusalem, 270a, Irvine Function constants of all aritys (convention: start with lower
case) motherOf, times, greaterThan, color
Relation constants, Predicates of all aritys (start with capital) B21, Parent, multistoried, XYZ, prime
Terms An object constant is a term A function constant of arity n followed by n terms in
parenthesis is a term (called functional expression) motherOf(Silvia), Sam, leftlegof(John), add1(5), times(5,plus(3,6))
Wffs sentences
An atomic sentence is formed from a predicate (relation) symbol followed by a parenthesized list of symbols
Atoms: a relation constant (predicate) followed by n terms in parenthesis seperated by commas.
GreaterThan(6,3), Q, Q(A,B,C,D), Brother(Richard,John) Married(FatherOf(Richard),MotherOf(John))
Complex propositional wffs:
Use logic connectives: Brother(Richard,John) /\ Brother(John,Richard) Older(John,30) V Younger(John,30) Older(John) --> ~Younger(John,30) V P
,,,
Semantics: Worlds
The world consists of objects that has properties. There are relations and functions between these objects Objects in the world, individuals: people, houses,
numbers, colors, baseball games, wars, centuries Clock A, John, 7, the-house in the corner, Tel-Aviv
Functions on individuals: father-of, best friend, third inning of, one more than
Relations: brother-of, bigger than, inside, part-of, has color, occurred after
Properties (a relation of arity 1): red, round, bogus, prime, multistoried, beautiful
Semantics: Interpretation
An interpretation of a wff is an assignment that maps object constants to objects in the worlds, n-ary function symbols to n-ary functions in the world, n-ary relation symbols to n-ary relations in the world
Given an interpretation, an atom has the value “true” in case it denotes a relation that holds for those individuals denoted in the terms. Otherwise it has the value “false”
Example: A,B,C,floor, On, Clear
World: On(A,B) is false, Clear(B) is true, On(C,F1) is true…
Semantics: Models
An interpretation satisfies a wff (sentence) if the wff has the value “true” under the interpretation.
An interpretation that satisfies a wff is a model of that wff
Any wff that has the value “true” under all interpretations is valid
Any wff that does not have a model is inconsistent or unsatisfiable
If a wff w has a value true under all the models of a set of sentences delta then delta logically entails w
Example of models
The formulas: On(A,F1) Clear(B) Clear(B) and Clear(C) On(A,F1) Clear(B) or Clear(A) Clear(B) Clear(C)Possible interpretations which are models:
On = {<B,A>,<A,floor>,<C,Floor>}Clear = {<C>,<B>}
Quantification
Universal and existential quantifiers allow expressing general rules with variables
Universal quantification All cats are mammals
It is equivalent to the conjunction of all the sentences obtained by substitution the name of an object for the variable x.
Syntax: if w is a wff then (forall x) w is a wff.
)( )( xMammalxCatx
,,,,
)()(
)()(
)()(
FelixMammalFelixCat
RebbekaMammalRebbekaCat
SpotMammalSpotCat
Quantification: Existential
Existential quantification : an existentially quantified sentence is true in case one of the disjunct is true
Equivalent to disjunction:
We can mix existential and universal quantification.
)(),( xCatspotxxSister
d)...Cat(Richarhard,Spot)Sister(Ric
Cat(Felix)ix,Spot)Sister(Fel
a)Cat(Rebeccecca,Spot)Sister(Reb
Cat(Spot)Spot)tSister(Spo
,
Useful Equivalences
De Morgan laws
Inference rules: Universal instantiation: foall x f(x) |-- f(alpha) Existential generalization: from f(alpha) |-- exist x f(x)
Modeling a domain; Conceptualization The kinship domain:
object are people Properties include gender and they are related by relations
such as parenthood, brotherhood,marriage predicates: Male, Female (unary)
Parent,Sibling,Daughter,Son... Function:Mother Father
Resolution in the predicate calculus Unification
Algorithm unify
Using unification in predicate calculus resolution Completeness and soundness Converting a wff to clause form The mechanics of resolution Answer extraction
Inference Rules in FOL
All the inference rules for propositional logic applies and additional three rules that use substitution; assigning constants to variables
Subst(x/constant) Subst({x/Sam,y/Pam},Likes(x,y)) = Likes(Sam,Pam)
Universal elimination From fromall x Likes(x,IceCream) we can substitute {x/Ben} and
infer Likes(Ben,IceCream) Existential Elimination
For any sentence and for any symbol k that does not appear elsewhere in the knowledge-base
exists x Kill(x,Victim) we can infer Kill(Murderer,victim) As long as Murdered soes not appear anywhere
Existential introduction From Likes(Jerry,IceCream) we can infer exists x Likes(x,IceCream)
Predicate calculus resolution
Suppose the 1 and 2 are two clauses represented as
set of literals. If there is an atom in 1 and a literal ~
in 2 such as and have a common unifier
Then these two clauses have a resolvent row. It is obtained by applying the substitution to 1 2
leaving out complementary literals
Example: xyfsubst
CxRAxPCBQAyfP
)(
)},(),({)},,()),(({
Converting to clause form
),(
)27,(
)28,()27,(
)(),(
),()28,()27,()()( ,
ABS
BI
AIAI
BPAP
yxSyIxIyPxPyx
Example: Answer Extraction
Example: Resoluction Refutation Prove I(A,27)
Rule-Based Systems
Rule-based Knowledge Representation and Inference combines rules
if DOG(x) then TAIL(X) with working memory,
DOG(SPOT) DOG(LUNA)
is not a formal knowledge representation scheme like logic somewhat like a combination of propositional and FOPL uses simple methods for inference often combined with other mechanisms such as inheritance motivated by practical use rather than theoretical properties also has some basis in cognitive models
Forward Chaining Procedure
While (rules can still fire or goal is not reached)for each rule in the rulebase which has not fired
1. try to bind premises by matching to assertions in WM
2. if all premises in a rule are supported then assert the conclusion and add to WM
Repeat 1. and 2. for all matching/ instantiation alternativesendcontinue
Example: Zoo Rulebase
Want to identify animals based on their characteristics could have rules like
if A1 and A2 and A3.....and A27 then animal is a monkey i.e., one very specific rule per animal
Better to use intermediate concepts e.g., the intermediate concept of a mammal if ?x is a mammal and B1...and B3 then ?x is a monkey
Why are intermediate concepts useful? rules are easier to create rulebase is easier to maintain easier to perform inference however: finding good intermediate concepts is non-trivial!
Where do the rules come from ?
Manual Knowledge Acquisition interview experts expert describes the rules process of translating expert knowledge into a formal representation is
also known as knowledge engineering this is notoriously difficult
experts are often very poor at explicitly describing what they do e.g., ask Michael Jordan how he plays basketball or ask Tiger Woods how he
plays golf
Automated Knowledge Acquisition derive rules automatically from formal specifications
e.g., by automatic analysis of solution manuals machine learning
learn rules from data
Inference Network Representation
We can represent forward chaining with rules as a network:has hair
eats meat
tawny color
black stripes
has a tail
is a tiger
is a carnivore
is a mammal
Inference using Backward Chaining
Establish a hypothesis e.g., Tony is a tiger a hypothesis is as assertion whose truth we wish to test
i.e., assert the hypothesis see if that is consistent with other data
Work backwards, i.e., match the hypothesis to the conclusion of the rules look at the premise conditions of the rule
if these are unknown, declare these as intermediate hypotheses backward chain recursively (depth-first manner)
Can use search algorithms to control how backward chaining proceeds
Inference Network Representation of Backward Chaining
• We can represent backward chaining as a network:
has hair
eats meat
tawny color
black stripes
is a tiger
is a carnivore
is a mammal
forward pointing eyeshas clawshas teeth
Backward Chaining ProcedureWhile (unsupported hypotheses exist or goal is not reached)
for each hypothesis Hfor each rule R whose conclusion matches with H
try to support each rule’s premises by1. matching assertions in WM2. recursively applying backward chaining
if rule’s premises are supported conclude that H is true
endend
continue
Forward Chaining or Backward Chaining:which is better? Which direction is better depends on the circumstances
4 main factors of relevance the number of possible start states and number of possible
goal states smaller is better
the branching factor in each direction smaller is better
what type of explanation the user wants more natural explanations may be important
the typical action which triggers a rule i.e., data-driven or hypothesis-driven?
What is a rule-based expert system (ES)?
ES performs a task in limited domains that require human expertise
medical diagnosis; fault diagnosis; status monitoring; data interpretation; mineral exploration; credit checking; tutoring; computer configuration
ES solves problems by application of domain specific knowledge rather than weak methods.
Domain knowledge is acquired by interviewing human experts
ES can explain a problem solution in human-understandable terms
ES cannot operate in situations that call for common sense
Examples of Expert Systems1965 DENDRAL Stanford analyze mass spectrometry data1965 MACSYMA MIT symbolic mathematics problems1972 MYCIN Stanford diagnosis of blood diseases1972 Prospector SRI Mineral Exploration1975 Cadeceus U. of PITT Internal Medicine1978 DIGITALIS MIT digitalis therapy advise1979 PUFF Stanford obstructive airway diseases1980 R1 CMU computer configuration1982 XCON DEC computer configuration1983 KNOBS MITRE mission planning1983 ACE AT&T diagnosis faults in telephone cables1984 FAITH JPL spacecraft diagnosis1986 ACES Aerospace satellite anomaly diagnosis1986 Cambpell diagnose cooker malfunctions1986 DELTA/CATS GE diagnosis of diesel locomotives1987 AMEX credit authorization1992 MAX NYNEX telephone network troubleshooting1995 Caltech PacBell network management1997 UCI planning drug treatment for HIV
Mycin: Diagnosis and treatment of blood diseasesRULESPREMISE ($AND (SAME CNTXT GRAM GRAMNEG) (SAME CNTXT MORH ROD) (SAME CNTXT AIR AEROBIC))ACTION: (CONCLUDE CNTXT CLASS ENTEROBACTERIACEAE .8)
If the stain of the organism is gramneg, and the morphology of the organism is rod, and
the aerobicity of the organism is aerobicTHEN there is strongly suggestive evidence (.8) that
the class of organism is enterocabateriaceae
DATAORGANISM-1:
GRAM = (GRAMNEG 1.0)MORP = (ROD .8) (COCCUS .2)AIR = (AEROBIC .6)(FACUL .4)
The XCON Application
A rule-based expert system expert in the sense that the rules capture expert design knowledge addresses a design/configuration problem
Digital Equipment Corporation (or Compaq by now!) XCON = rule-based expert system for computer configuration decides how peripherals are configured on new orders has 10,000 rules developed in early 1980’s based on “reactive rule-based systems”
if antecedents then action forward chaining in style
estimated to have saved DEC several hundred million $’s
Limitations of Rule-Based Representations
Can be difficult to create the “knowledge engineering” problem
Can be difficult to maintain in large rule-bases, adding a rule can cause many unforeseen
interactions and effects => difficult to debug
Many types of knowledge are not easily represented by rules uncertain knowledge: “if it is cold it will probably rain” information which changes over time procedural information (e.g. a sequence of tests to diagnose a
disease)
Summary
Knowledge Representation methods formal logic rule-based systems (less formal)
Rule-based representations are composed of Working memory: Rules
Inference occurs by forward or backward chaining
Rule-based expert systems useful for certain classes of problems which do not have direct algorithmic solutions
have their limitations