CSCI-495 Artificial Intelligence Lecture 17
Tractable Inference: Horn Logic Resolution in general can be exponential in space and time For tractable inference we need a smaller logic Real-world KBs often contain only clauses of a restricted kind called Horn clauses A Horn clause is a disjunction of literals of which at most one is positive Equivalent to A B C B C A α β with α β (i.e., premise is a conjunction of positive literals, conclusion is a single positive literal)
Tractable Inference: Horn Logic Inference (via forward checking, backward checking) can be done in time linear in the size of the KB. Both of these algorithms are also very natural, in that the inference steps are obvious and easy to follow for humans Human knowledge has this form, easy and simple to write diagnostic rules expert system People find it easy to read and write sentences in this form for many domains of knowledge
Forward Chaining
Forward Chaining: Graph Representation OR Gate AND gate
Forward Chaining: Example
Forward Chaining: Example
Forward Chaining: Example
Forward Chaining: Example
Forward Chaining: Example
Forward Chaining: Example
Forward Chaining: Example
Forward Chaining: Example
Forward Chaining The time complexity of the algorithm is linear in the size of the KB It is easy to see that Forward Chaining is sound Every inference is essentially an application of Modus Ponens
Forward Chaining An example of data-driven reasoning In humans, a certain amount of data-driven reasoning as new information arrives I hear rain starting to fall It might occur to me that the picnic will be cancelled It will probably not occur to me that the seventeenth petal on the largest rose in my neighbor s garden will get wet We keep Forward Chaining under careful control
Backward Chaining A form of goal-directed reasoning Where are my keys? Often the cost of Backward Chaining is much less that linear in the size of the KB because the process touches only relevant facts Idea: work backwards from the query q check if q is known already, or prove by BC all premises of some rule concluding q Hence BC maintains a stack of sub-goals that need to be proved to get to q Like FC, is linear and is also sound and complete (for Horn KB)
A Propositional Logic Wumpus Hunter It begins with a KB that states the physics of the wumpus world It knows that [1,1] does not contain a pit or wumpus (2 sentences) P 1,1 and W 1,1 for every square [x, y], how a breeze arises (16 sentences) B x,y (P x,y+1 v P x,y-1 v P x+1,y v P x-1,y ) for every square [x, y], how a stench arises (16 sentences) S x,y (W x,y+1 v W x,y-1 v W x+1,y v W x-1,y ) there is exactly one wumpus W 1,1 v W 1,2 v v W 4,3 v W 4,4 (to say at least one) W 1,1 v W 1,2 for any two squares (to say at most one) (121 sentences) A total of 155 sentences for 4x4 world
Propositional Logic is a weak language Hard to identify individuals (e.g., Mary, 3) Can t directly talk about properties of individuals or relations between individuals (e.g., Bill is tall ) Generalizations, patterns, regularities can t easily be represented (e.g., all triangles have 3 sides )
First-Order Logic Propositional logic assumes the world contains facts First-order logic (like natural language) assumes the world contains Objects: people, houses, numbers, colors, baseball games, wars, Relations: red, round, prime, brother of, bigger than, part of, comes between, Functions: father of, best friend, one more than, plus,
First-Order Logic Almost any assertion can be thought as referring to objects and properties or relations One plus two equals three Squares neighboring the wumpus are smelly Evil King John ruled England in 1200
Models for FOL Remember that the models of a logical language are the formal structures that constitute the possible worlds under consideration (e.g., in PL, sets of truth values of the propositional symbols) Models in FOL have objects in them! The domain of a model is the set of objects it contains (i.e., the domain elements) The domain elements may be related in various ways. A relation is just the set of tuples of objects that are related
Models for FOL: Example Objects? Relations? Functions?
Syntax of FOL: Basic elements Constant Symbols Stand for objects e.g., KingJohn, 2, StFX,... 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 Constants KingJohn, 2, UCI,... Predicates Brother, >,... Functions Sqrt, LeftLegOf,... Variables x, y, a, b,... Connectives,,,, Equality = Quantifiers,
Relations Some relations are properties: they state some fact about a single object Round(ball), Prime(7) n-ary relations state facts about two or more objects Married(John,Mary), LargerThan(3,2) Some relations are functions: their value is another object Plus(2,3), Father(Dan)
Terms Term = logical expression that refers to an object There are 2 kinds of terms: constant symbols: Table, Computer function symbols: LeftLeg(Pete), Sqrt(3), Plus(2,3) etc
Atomic Sentences An atomic sentence, which has value true or false, states a fact and is an n-place predicate of n terms LargerThan(3,2) Brother_of(Pete,Mary) Married(Father(Richard), Mother(John)) Note: Functions do not state facts and form no sentence: Brother(Pete) refers to John (his brother) and is neither true nor false
Complex Sentences We make complex sentences with connectives (just like in propositional logic) property Brother ( LeftLeg ( Richard ), John ) ( Democrat ( Bush)) binary relation function objects connectives
More Examples Brother(Richard, John) Brother(John, Richard) King(Richard) King(John) King(John) => King(Richard) LessThan(Plus(1,2),4) GreaterThan(2,1) (Semantics are the same as in propositional logic)
Variables Person(John) is true or false because we give it a single argument 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))