220 likes | 234 Views
Artificial Intelligence. Lecture 4. Faculty of Computer Science International Islamic University Islamabad. Pakistan. Predicate Calculus. Predicate Calculus An extension to propositional calculus. Predicates to describe relationships Allow variables in expressions
E N D
Artificial Intelligence Lecture 4 Faculty of Computer Science International Islamic University Islamabad. Pakistan
Predicate Calculus Predicate Calculus • An extension to propositional calculus. • Predicates to describe relationships • Allow variables in expressions • Example "I am in Paris" • propositional symbol P to denote the sentence • predicate place describes the relationship of I and Paris: place(I, paris) • predicate place(X,paris) denotes whether X is in Paris • place(I,Y) denotes whether I am at Y
Using Inference Rules to Produce Predicate Calculus Expressions • The ability to infer new correct expressions from a set of true assertions is an important feature of the predicate calculus. • These new expressions are correct in that they are ‘consistent’ with all previous interpretations of the original set of expressions. • S: a set of predicate calculus sentences "X ( human(X) a mortal(X) ) • I: An interpretation human(bill_gates) • X: an expression logically from S mortal(bill_gates)
The letters ‘B’ and ‘C’ represent proper names ‘Bob’ and ‘Cathy’. ‘m’ is one-place predicate meaning ‘is a mechanic’. ‘n’ is one-place predicate meaning ‘is a nurse’. ‘t’ is two-place predicate meaning ‘is taller than’. • Either Cathy is a mechanic or a nurse (or both). • m(C) v n(C). • If Cathy is a mechanic then she is not a nurse. • m(C) a ~n(C). • Cathy is taller than Bob. • t(C,B). • For any three objects, if the first is taller than the second and the second is taller than the third, then the first is taller than the third. • "X "Y "Z ( t(X, Y) ^ t(Y, Z) a t(X, Z) ). Exercise
First Order Predicate Calculus First Order Predicate Calculus • First-order predicate calculus: universally and existentially quantified variables refer only to objects (constants), not to predicates or functions • valid expressions: V X likes(kin,X) and E X V Y likes(X,Y) • - invalid expression: V (likes) likes(kin,ice_cream) • this is valid in second order predicate calculus
Inference Rules Inference Rules • Ability of producing new, correct predicate calculus sentences from an original set of predicate calculus sentences Modus Ponens: • given: P=>Q and P are true • conclusion: Q is true • Example: • P=>Q: “If I am in Paris then I am in France” • P: “I am in Paris” • Q: “I am in France” added to P=>Q and P
Inference Rules Modus Tolens: • given: P=>Q is true, and Q is false • conclusion: P is false • Example: • P=>Q: “If I am in Paris then I am in France” • ~Q: “I am not in France” • ~P: “I am not in Paris” added to P=>Q and ~Q
Inference Rules(Resolution) Inference Rules • Resolution: • given: PvQ and ~QvR are true • conclusion: PvR is true Universal instantiation: • given: V X p(X) is true, and constant x is from the domain of X • conclusion: p(x) is true • example: all birds have feathers and a penguin is a bird • conclusion: penguin has feathers
Unification Unification • The process of finding the substitutions needed to make two predicate calculus expressions match. • Example: {foo(X,a,goo(Y), foo(fred, a, goo(Z))} • - Substitution {fred/X} yields {foo(fred,a,goo(Y), foo(fred, a, goo(Z))} • - substitution: {fred/X, Z/Y} yields {foo(fred,a,goo(Z), foo(fred, a, goo(Z))} • - here ‘fred/X’ indicates that ‘fred’ is substituted for the variable X or the variable X is said to be bound to the value ‘fred’ Unification Rules • a variable may be replaced by a constant: c/X • a variable may be replaced by a variable: Y/X • a variable may be replaced by a function expression as long as the function expression does not contain the variable: p(Y)/X • once a variable has been bound, future unification and inferences must take this substitution into account
Unification is an algorithm for determining the substitutions needed to make two predicate calculus expressions match. Unification Substitutions alpha( X, a, beta(Y) ). Is to be unified with • alpha( fred, a, beta(Z) ). • alpha( W, a, beta(jack) ). • alpha( Z, a, beta( beta(Z) ) ). • In this example, the unifications that would make the original expression identical to each of the other three are written as: • { fred / X, Z / Y } • { W / X, jack / Y } • { Z / X, beta(Z) / Y} • The notation X / Y indicates that X is substituted for the variable Y. Substitutions are also called ‘bindings’. Unification
Composition of Unification Substitutions Consider the following sequence of substitutions: { X / Y, W / Z }, { V / X }, { a / V, f(b) / W } These are equivalent to the single substitution {a / Y, f(b) / Z } Steps involved were • Compose { X / Y, W / Z } with { V / X } to give { V / Y, W / Z } • Compose { V / Y, W / Z } with {a / V, f(b) / W } to give { a / Y, f(b) / Z } • If S and S’ are two substitution sets, then composition of S and S’ (written as S’S) is obtained by applying S to the elements of S’ and adding the results to S. Unification
Examples • Emma is a Doberman pinscher and a good dog: Googdog(emma) ^ isa(emma,doberman) • every dog is an animal: V X (dog(X) => animal (X)) • every boy has a bicycle: • V X (E Y (boy(X) => (bicycle(Y) ^ own(X,Y))))
Application: A Logic-Based Financial Advisor Application: A Logic-Based Financial Advisor • 1. People with inadequate savings should increase their savings, regardless of income. • 2. People with adequate savings and an adequate income should consider a riskier but potentially more profitable investment in the stock market. • 3. People with a lower income who already have adequate savings should split their investment between savings and stocks, to increase the cushion in savings while attempting to increase their income through stocks. • 4. Adequate savings is to have more than $5,000 in the bank for each dependent. • 5. Adequate income is steady, more than $15,000 plus $4,000 for each dependent.
Application: A Logic-Based Financial Advisor • The above set of logical sentences describes the problem domain. The assertions are numbered so that they may be referenced in the following trace: • Using unification and modus ponens, a correct investment strategy for this individual may be inferred as a logical consequence of the above descriptions. A first step would be to unify the conjunctions of 11 and 13 with the first two components of the premise of 7 i.e, • earnings(25000,steady) ^ dependents(3) unifies with earnings(X,steady) ^ dependents(Y) • Under the substitutions {25000/X, 3/Y}. This substitution yields the new implication.
Application: A Logic-Based Financial Advisor • earnings(25000,steady)^dependents(3)^~greater(25000,minincome(3))=>income (inadequate). • earnings(25000,steady)^dependents(3)^~greater(25000,27000)=> income (inadequate). • All three components of the premise are individually true, by 3, 11, and the mathematical definition of greater, their conjunction is true and the entire premise is true. Now, Modus ponens may therefore be applied, yielding the conclusion income (inadequate). This is added as a new assertion. • 14. income (inadequate)
Application: A Logic-Based Financial Advisor • Similarly, amount_saved(22000)^dependents(3) unifies with the first two elements of the premise of assertion 4 under the substitution {22000/X,3/Y} yielding the implication: • amount_saved(22000)^dependents(3)^greater(22000,minsavings(3))=>savings_account(adequate). • Here, evaluating the function minsavings(3) yields: • amount_saved(22000)^dependents(3)^greater(22000,15000)=>savings_account(adequate). • It yields the conclusion: • 15. savings_account(adequate). So after applying Modus ponens on 14, 15 & 3
Application: A Logic-Based Financial Advisor • 3.savings_account(adequate)^income(inadequate)=> investment (combination). • This will be the suggested investment of this individual. • The above application shows how predicate calculus may be used to reason about a realistic problem, drawing correct conclusions by applying inference rules to the initial problem description. In the later lectures, we will discuss, how these things can be implemented on a computer.
Home Work • Read chapter 2 of George F. Luger along with the handout on Predicate Calculus. • Try to convert as many sentences as you can in Predicate Calculus. • Try to implement Unification and unify the predicate expressions • We will do Resolution Theorem Proving in the next lecture ref: ch.12 Luger……………..it includes predicate, unification, modus ponens, refutation along with other stuff covered so far…..
Assignment No 1 • Implement the algorithm verifiy_sentence from chapter no 2 of the book by George F. Luger in any computer language of your choice. • Due date October 25th, 2010. • Submit the code (.cpp) and (.exe) files in the in assign1_roll_number folder with your registration # as your file names. 04-123.cpp • Add as many comments as possible in your code file, so that documentation won’t be required.