Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 FOL CS 331/531 Dr M M Awais Unification “It is an algorithm for determining the substitutions needed to make two predicate calculus expressions match”

Similar presentations


Presentation on theme: "1 FOL CS 331/531 Dr M M Awais Unification “It is an algorithm for determining the substitutions needed to make two predicate calculus expressions match”"— Presentation transcript:

1 1 FOL CS 331/531 Dr M M Awais Unification “It is an algorithm for determining the substitutions needed to make two predicate calculus expressions match” Reference: Luger’s Book chapter 3, 2 nd edition

2 2 FOL CS 331/531 Dr M M Awais Implementation of Unification Using“List format” (PNF have already been discussed) PC SyntaxList Syntax p(a,b)(p a b) p(f(a), g(X,Y))(p(f a)(g X Y)) p(x) ^ q(y)((p x) ^ (q y))

3 3 FOL CS 331/531 Dr M M Awais Unification: Examples Unify ( (parents X(father X) (mother bill)), (parents bill (father bill)Y) ). Complete Substitution {bill/X, mother (bill)/Y}

4 4 FOL CS 331/531 Dr M M Awais

5 5 FOL CS 331/531 Dr M M Awais

6 6 FOL CS 331/531 Dr M M Awais

7 7 FOL CS 331/531 Dr M M Awais Logic – Based Financial Advisor To help a user decide whether to invest in a saving A/C or the stock market or both

8 8 FOL CS 331/531 Dr M M Awais Policy: Saving inadequate - should invest in saving A/c regardless of income Saving adequate and adequate income - More profitable option of stock investment Low Income & adequate savings - Split surplus between saving and stock investment

9 9 FOL CS 331/531 Dr M M Awais Defining Constraints Adequate Savings/Income: Income:Rs 15,000/month extra Rs 4000/ dependent/month Saving:Rs 25,000/year extra Rs 5000/dependent/year

10 10 FOL CS 331/531 Dr M M Awais Calculating Adequacy Define Functions to calculate the minimum income and savings Minimum Savings:min_saving(X) min_saving(X)=25000+5000*X Minimum Income:min_income(X) min_income(X)=15000+4000*X where X are the number of dependents

11 11 FOL CS 331/531 Dr M M Awais Outputs Investment (savings) Investment (stocks) Investment (combination) How can we represent outputs?

12 12 FOL CS 331/531 Dr M M Awais Rules  saving_acc (inadequate)  investment (savings)  saving_acc(adequate) ^ income(adequate)  investment(stocks)  saving_acc (adequate) ^ income (inadequate)  investment (combination)

13 13 FOL CS 331/531 Dr M M Awais What next? Define saving adequate Define saving inadequate Define income adequate Define income inadequate

14 14 FOL CS 331/531 Dr M M Awais Savings Check if saved amount is greater than the minimum saving required

15 15 FOL CS 331/531 Dr M M Awais Income Check if the income is greater than the minimum income

16 16 FOL CS 331/531 Dr M M Awais Try firing rules with 9, 10, 11

17 17 FOL CS 331/531 Dr M M Awais Example knowledge base The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American. Prove that Col. West is a criminal Solution presented using alternate syntax Reference: Norviq and Russell

18 18 FOL CS 331/531 Dr M M Awais Example knowledge base contd.... it is a crime for an American to sell weapons to hostile nations: American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x) Nono … has some missiles, i.e.,  X Owns(Nono,x)  Missile(x): Owns(Nono,M 1 ) and Missile(M 1 )(skolemization) … all of its missiles were sold to it by Colonel West Missile(x)  Owns(Nono,x)  Sells(West,x,Nono) Missiles are weapons: Missile(x)  Weapon(x) An enemy of America counts as "hostile“: Enemy(x,America)  Hostile(x) West, who is American … American(West) The country Nono, an enemy of America … Enemy(Nono,America)

19 19 FOL CS 331/531 Dr M M Awais Example knowledge base contd. Rule Base:... it is a crime for an American to sell weapons to hostile nations: R1: American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x) Nono … has some missiles, i.e., R2 R2:  x Owns(Nono,x)  Missile(x) … all of its missiles were sold to it by Colonel West R3 R3: Missile(x)  Owns(Nono,x)  Sells(West,x,Nono) Missiles are weapons: R4: R4: Missile(x)  Weapon(x) An enemy of America counts as "hostile“: R5 R5: Enemy(x,America)  Hostile(x) Database of Facts: Owns(Nono,M 1 ) ^ Missile(M 1 ) West, who is American … American(West) The country Nono, an enemy of America … Enemy(Nono,America)

20 20 FOL CS 331/531 Dr M M Awais START FROM THE FACTS THINK WHICH RULES APPLY Be careful about the convention constants start with capital letters and variables with small (applicable to next few slides) R1: American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x) R2:  x Owns(Nono,x)  Mssile(x) R3: Missile(x)  Owns(Nono,x)  Sells(West,x,Nono) R4: Missile(x)  Weapon(x) R5: Enemy(x, America)  Hostile(x) 1. FORWARD CHAINING

21 21 FOL CS 331/531 Dr M M Awais R4 {M1/x} R3 {M1/x} R5 {Nono/x} R1: American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x) R2:  x Owns(Nono,x)  Mssile(x) R3: Missile(x)  Owns(Nono,x)  Sells(West,x,Nono) R4: Missile(x)  Weapon(x) R5: Enemy(x, America)  Hostile(x)

22 22 FOL CS 331/531 Dr M M Awais R1 {West/x, M1/y, Nono/z} R1: American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x) R2:  x Owns(Nono,x)  Mssile(x) R3: Missile(x)  Owns(Nono,x)  Sells(West,x,Nono) R4: Missile(x)  Weapon(x) R5: Enemy(x, America)  Hostile(x)

23 23 FOL CS 331/531 Dr M M Awais 2. BACKWARD CHAINING START FROM THE CONCLUSION THINK IS THE RULE SUPPORT AVAILABLE R1: American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x) R2:  x Owns(Nono,x)  Mssile(x) R3: Missile(x)  Owns(Nono,x)  Sells(West,x,Nono) R4: Missile(x)  Weapon(x) R5: Enemy(x, America)  Hostile(x)

24 24 FOL CS 331/531 Dr M M Awais Backward chaining example West/x

25 25 FOL CS 331/531 Dr M M Awais Backward chaining example West/x

26 26 FOL CS 331/531 Dr M M Awais Backward chaining example West/x

27 27 FOL CS 331/531 Dr M M Awais Backward chaining example West/x, M1/y M1/y

28 28 FOL CS 331/531 Dr M M Awais Backward chaining example West/x, M1/y, Nono/z M1/y Nono/z

29 29 FOL CS 331/531 Dr M M Awais Backward chaining example West/x, M1/y, Nono/z M1/y Nono/z

30 30 FOL CS 331/531 Dr M M Awais Backward chaining example West/x, M1/y, Nono/z M1/y Nono/z


Download ppt "1 FOL CS 331/531 Dr M M Awais Unification “It is an algorithm for determining the substitutions needed to make two predicate calculus expressions match”"

Similar presentations


Ads by Google