1 FOL CS 331/531 Dr M M Awais Composition Find Overall Substitutions Given two or more sets of substitutions.

Slides:



Advertisements
Similar presentations
Inference in first-order logic
Advertisements

First-Order Logic.
Inference Rules Universal Instantiation Existential Generalization
Standard Logical Equivalences
ITCS 3153 Artificial Intelligence Lecture 15 First-Order Logic Chapter 9 Lecture 15 First-Order Logic Chapter 9.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
1 FOL CS 331/531 Dr M M Awais Composition Find Overall Substitutions Given two or more sets of substitutions.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
Artificial Intelligence Inference in first-order logic Fall 2008 professor: Luigi Ceccaroni.
Some Thoughts to Consider 7 What is the difference between Knowledge Engineering and Programming? What is the difference between Knowledge Engineering.
Web Science & Technologies University of Koblenz ▪ Landau, Germany Implementation Techniques Acknowledgements to Angele, Gehrke, STI.
Production Systems Productions systems are rule based forward chaining systems. They are based on forward chained reasoning, but are extended to be a kind.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Inference in FOL All rules of inference for propositional logic apply to first-order logic We just need to reduce FOL sentences to PL sentences by instantiating.
First-Order Logic Inference
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”
1 FOL Resolution based Inferencing Resolution based rules studied earlier can lead to inferences, rules such as modus ponen, unit resolution etc… Other.
1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA.
Inference and Resolution for Problem Solving
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Fall 2004.
Inference in First-Order Logic Inference Rules with Quantifiers The three new inference rules are as follows: Universal Elimination: For any sentence ,
1 Inference in First-Order Logic. 2 Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward chaining.
CSC411Artificial intelligence 1 Chapter 2 The Predicate Calculus Contents The Propositional Calculus The Predicate Calculus Using Inference Rules to Produce.
Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA.
Inference in First-Order Logic CS 271: Fall 2007 Instructor: Padhraic Smyth.
Inference in first-order logic I CIS 391 – Introduction to Artificial Intelligence AIMA Chapter (through p. 278) Chapter 9.5 (through p. 300)
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Propositional Calculus Composed of symbols –P – some true statement P might represent something like “It is Monday” or “the car is red” And sentences –a.
1 Chapter 8 Inference and Resolution for Problem Solving.
CS 416 Artificial Intelligence Lecture 12 First-Order Logic Chapter 9 Lecture 12 First-Order Logic Chapter 9.
Inference in first- order logic. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward chaining.
Computing & Information Sciences Kansas State University Friday, 29 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 16 of 42 Friday, 29 September.
Inference in First-Order Logic 부산대학교 전자전기컴퓨터공학과 인공지능연구실 김민호
1 Inference in First-Order Logic CS 271: Fall 2009.
An Introduction to Artificial Intelligence – CE Chapter 9 - Inference in first-order logic Ramin Halavati In which we define.
1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.
Inference in first-order logic
Inference in First Order Logic. Outline Reducing first order inference to propositional inference Unification Generalized Modus Ponens Forward and backward.
Artificial Intelligence Lecture 4 Faculty of Computer Science International Islamic University Islamabad. Pakistan.
Inference in First-Order Logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
1 Chaining in First Order Logic CS 171/271 (Chapter 9, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Knowledge Representation using First-Order Logic
Presented By S.Yamuna AP/CSE
Inference in first-order logic
Logical Agents Chapter 7.
School of Computer Science & Engineering
Inference in First-Order Logic
The function of knowledge representation scheme is
Knowledge Representation & Reasoning
Inference in First-Order Logic
Inference in first-order logic part 1
Example of Knowledge Base
Artificial intelli-gence 1:Inference in first-order logic
Artificial Intelligence
Artificial intelligence: Inference in first-order logic
Artificial Intelligence Inference in First Order Logic
Inference in first-order logic
Inference in first-order logic part 1
First-Order Logic Inference
An Application in Prolog
CS 8520: Artificial Intelligence
First-Order Logic Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

1 FOL CS 331/531 Dr M M Awais Composition Find Overall Substitutions Given two or more sets of substitutions

2 FOL CS 331/531 Dr M M Awais Composition Domain: Variables in the substitution together form the domain (denominators) S1={a/X1, b/X2, …z/Xn} Then Dom(S1)={X1, X2, …Xn} St={a/B} B is the domain or Dom(St) Replacements: Terms are the replacements (numerators) Rep(S1)={a,b,…z} St={a/B}a is the replacement or Rep(St)

3 FOL CS 331/531 Dr M M Awais Composition Rule Two substitutions S1 and S2 can compose in two ways: S1 composed with S2S12 or S1.S2 S2 composed with S1S21 or S2.S1 S12 is obtained by applying S2 to S1 Adding S2 to the set obtained in step 1 Removing substitutions from the above (newly added substitutions i.e., S2 that have Dom(S2)=Dom(S1)

4 FOL CS 331/531 Dr M M Awais Step 1: Applying S2 to S1 Finding Dom(S2) Finding Rep(S1) If elements of Dom(S2) = elements of Rep(S1) S2 applies to S1 otherwise does not. Example: S1={W/A,e/D}, S2={s/W,g/K} Step 1: Dom(S2)={W, K}, Rep(S1)={W,e}, W matches hence apply (S2 to S1) s/W to W/A generate s/A Hence the new set obtained after applying S2 to S1 is: S12={s/A,e/D}

5 FOL CS 331/531 Dr M M Awais Step 2&3: Add+Drop Step 2: Add S2 to S12={s/A,e/D} S12={s/A,e/D, s/W,g/K} Step 3: Drop any where Dom(S2)=Dom(S12 in step 1) from substitutions of S2 added in step 2. Nothing gets dropped Final Answer: S12={s/A,e/D, s/W,g/K}

6 FOL CS 331/531 Dr M M Awais Composition S1={A/D} S2={D/X} What is possible S12 or S21 or both? D is in the domain in S1, and replacement in S2 A is the replacement in S1 X is the domain in S2 S1 can be applied to S2, as the domain of S1(D) is the replacement in S2. Hence S2 modifies as {A/X} S2 cannot be applied to S1, as the domain of S2 is not a replacement in S1, S1 remains{A/D}

7 FOL CS 331/531 Dr M M Awais Composition S1={A/K} replacements=A, domain=K S2={a/A} replacements=a, domain=A S21 Apply S1 to S2 Cannot be applied as K is not a replacement in S2.{a/A} Non Composable S12 Apply S2 t S1 Can be applied, as A is a replacement in S1, {a/K} Composable

8 FOL CS 331/531 Dr M M Awais Composition S1={A/K,f/M} replacements=A,f domain=K,M S2={a/A,j/R} replacements=a,j domain=A,R Apply S1 to S2 A/K Cannot be applied as K is not a replacement in S2. F/M Cannot be applied as M is not a replacement in S2 {a/A,j/R} Non Composable Apply S2 t S1 a/A can be applied, as A is a replacement in S1, {a/K} J/R cannot be applied as R is not a replacement in S1 {a/K, f/M} Composable

9 FOL CS 331/531 Dr M M Awais Example S1={A/K} S2={a/A, H/J} S12={a/K, a/A,H/J} Algorithm 1. Apply S2 to S1 (find overall substitution) and generate a modified S1 2. Add to the answer in Step 1 all the substitutions of S2 (combined +uncombined) 3. Drop all substitutions in S2 which have common denominators with S12

10 FOL CS 331/531 Dr M M Awais Example: S12 S1={A/K} S2={a/A, H/J} Algorithm for S12: Apply S2 to S1 See if A and J are present among the replacements of S1 if Yes replace A with a and J with H This would generate {a/K} Add S2 to S1 (Modified S1 in step 1+ all of S2) Modified S1={a/K} + {a/A,H/J} Drop all substitutions in S2 which have common denominators with S1 nothing gets dropped, hence the answer is S12={a/K,a/A,H/J}

11 FOL CS 331/531 Dr M M Awais Example: S21 S1={A/K} S2={a/A, H/J} Algorithm for S21: Apply S1 to S2 See if K is present among the replacements of S2 if Yes replace K with A (no change in S2) This would generate {a/A, H/J} Add S1 to S2 (Modified S2 in step 1+ all of S1) Modified S1={a/A,H/J}+{A/K} Drop all substitutions in S1 which have common denominators with S2 nothing gets dropped, hence the answer is S12={a/A,H/J,A/K}

12 FOL CS 331/531 Dr M M Awais Example S1={D/A} S2={a/D} S12 Step 1: Combining (S2 to S1)S12={a/A} Step 2:Addition (Add S2)S12={a/A}+{a/D} Step 3: DropS12={a/A,a/D} S1={D/A,S/G,n/N} S2={x/X, f/D, q/S,w/A} S12 Step 1:CombiningS12={f/A,q/G,n/N} Step 2:Addition S12={f/A,q/G,n/N}+{x/X, f/D, q/S,w/A} Step 3: DropS12={f/A,q/G,n/N,x/X,f/D,q/S}

13 FOL CS 331/531 Dr M M Awais Is S12 same as S21 S1={D/A} S2={a/D} S21 Step 1: Combine (S1 to S2)S2={a/D} Combination cannot possible because no A is present in S2, so cannot replace with D, output is same as S2 Step 2: AddS21={a/D}+{D/A} Step 3: DropS21={a/D,D/A} S1={D/A,S/G,n/N} S2={x/X, f/D, q/S,w/A} S21 Step 1: CombineS2={ x/X, f/D, q/S,w/A } Step 2: AddS2={ x/X, f/D, q/S,w/A }+{D/A,S/G,n/N} Step 3: DropS21={ x/X, f/D, q/S,w/A, S/G,n/N}

14 FOL CS 331/531 Dr M M Awais Is S12 same as S21 S1={D/A} S2={X/A} S12={D/A} Combine:S12={D/A} Add:S12={D/A}+{X/A} Drop:S12={D/A} X/A gets dropped S21={X/A} Combine:S21={X/A} Add:S21={X/A}+{D/A} Drop:S21={X/A} D/A gets dropped

15 FOL CS 331/531 Dr M M Awais Example S1={D/A, d/F,S/E} S2={g/D} S12={g/A, d/F, S/E, g/D} S12={g/A, d/F, S/E, g/D} (nothing gets dropped) S21={g/D, D/A, d/F, S/E} S21={g/D, D/A,d/F,S/E} (nothing gets dropped)

16 FOL CS 331/531 Dr M M Awais Example S1={a/A,b/B,c/C} S2={A/X,B/Y,S/Q} S12={a/A,b/B,c/C} + {A/X,B/Y,S/Q} S12={a/A, b/B, c/C, A/X, B/Y, S/Q} S21= {a/X, b/Y, S/Q} + {a/A,b/B,c/C} S21={a/X, b/Y, S/Q, a/A, b/B, c/C}

17 FOL CS 331/531 Dr M M Awais Substitution: Discussion Domain: Variables in the substitution together form the domain (denominators) Replacements: Terms are the replacements (numerators) Pure Vs Impure Substitutions: A pure substitution is if all replacements are free of the variables in the domain of the substitution. Otherwise impure {s/X, t/I, j/G} (pure) The composition of pure substitutions may be impure and vice versa Composability:

18 FOL CS 331/531 Dr M M Awais Application Example Knowledge base: knows(ali,sana) knows(X,shahid)knows(X,Y) We also know knows(ali,X)  hates(ali,X) Unify the conditions to find ali hates whom unify(knows(ali,X), knows(ali,sana)) = {sana/X} Using the binding and the rule: ali hates sana unify(knows(ali,X), knows(X,shahid)) = {ali/X,shahid/X} This would fail as X cannot have two values at the same time As the composition of {ali/X} with {shahid/X} or vice versa will result in only one valid substitution unify(knows(ali,X), knows(X,Y)) = {ali/X,X/Y} This would mean that ali knows everyone including himself, therefore hates everyone.

19 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

20 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))

21 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}

22 FOL CS 331/531 Dr M M Awais

23 FOL CS 331/531 Dr M M Awais

24 FOL CS 331/531 Dr M M Awais

25 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

26 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

27 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

28 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)= *X Minimum Income:min_income(X) min_income(X)= *X where X are the number of dependents

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

30 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)

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

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

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

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

35 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

36 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)

37 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)

38 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

39 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)

40 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)

41 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)

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

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

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

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

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

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

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