Artificial Intelligence Lecture 4 Faculty of Computer Science International Islamic University Islamabad. Pakistan.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

First Order Logic Logic is a mathematical attempt to formalize the way we think. First-order predicate calculus was created in an attempt to mechanize.
The Foundations: Logic and Proofs
1 A formula in predicate logic An atom is a formula. If F is a formula then (~F) is a formula. If F and G are Formulae then (F /\ G), (F \/ G), (F → G),
Resolution.
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
First Order Logic Resolution
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.
Logic Use mathematical deduction to derive new knowledge.
Predicates and Quantifiers
L41 Lecture 2: Predicates and Quantifiers.. L42 Agenda Predicates and Quantifiers –Existential Quantifier  –Universal Quantifier 
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
CS128 – Discrete Mathematics for Computer Science
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
NEWELL & SIMON All sciences characterize the essential nature of the systems they study. These characteristics are invariably qualitative in nature, for.
Inference and Resolution for Problem Solving
Chapter 3 Propositional Logic
Artificial Intelligence
CSC411Artificial intelligence 1 Chapter 2 The Predicate Calculus Contents The Propositional Calculus The Predicate Calculus Using Inference Rules to Produce.
Introduction to Logic for Artificial Intelligence Lecture 2 Erik Sandewall 2010.
The Foundations: Logic and Proofs
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
The Predicate Calculus
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.
Chap. 2 Fundamentals of Logic. Proposition Proposition (or statement): an declarative sentence that is either true or false, but not both. e.g. –Margret.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
ARTIFICIAL INTELLIGENCE Lecture 3 Predicate Calculus.
1.  Provides the ability to access individual assertions. e.g. in Predicate calculus we may say: P denotes “It rained on Tuesday” but in predicate calculus.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
1 Predicate (Relational) Logic 1. Introduction The propositional logic is not powerful enough to express certain types of relationship between propositions.
Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems or solving problems, creativity and insight.
Hazırlayan DISCRETE COMPUTATIONAL STRUCTURES Propositional Logic PROF. DR. YUSUF OYSAL.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
1 Introduction to Abstract Mathematics Expressions (Propositional formulas or forms) Instructor: Hayk Melikya
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
1 Introduction to Abstract Mathematics Chapter 2: The Logic of Quantified Statements. Predicate Calculus Instructor: Hayk Melikya 2.3.
Propositional Logic Predicate Logic
Chapter 2 Fundamentals of Logic 1. What is a valid argument or proof?
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 11 The Foundations: Logic and Proofs Rules of inference.
PREDICATE CALCULS In Propositional Calculus, each atomic symbol denotes a proposition. But there is no way to access the components of an individual assertion.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Lecture 041 Predicate Calculus Learning outcomes Students are able to: 1. Evaluate predicate 2. Translate predicate into human language and vice versa.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Chapter 3 Propositional calculus Predicate calculus Artificial Intelligence Dr.Hassan Al-Tarawneh.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU1 Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems.
Propositional and predicate logic
March 3, 2016Introduction to Artificial Intelligence Lecture 12: Knowledge Representation & Reasoning I 1 Back to “Serious” Topics… Knowledge Representation.
Uniqueness Quantifier ROI for Quantified Statement.
Chapter 1 Logic and proofs
Propositional Calculus
Introduction to Logic for Artificial Intelligence Lecture 2
Knowledge Representation and Reasoning
Discrete Mathematics Logic.
The function of knowledge representation scheme is
The Foundations: Logic and Proofs
CS201: Data Structures and Discrete Mathematics I
Back to “Serious” Topics…
Computer Security: Art and Science, 2nd Edition
Discrete Mathematics Logic.
Predicates and Quantifiers
Propositional Calculus
CS201: Data Structures and Discrete Mathematics I
Presentation transcript:

Artificial Intelligence Lecture 4 Faculty of Computer Science International Islamic University Islamabad. Pakistan

Predicate Calculus An extension to propositional calculus. An extension to propositional calculus. Predicates to describe relationships Predicates to describe relationships Allow variables in expressions Allow variables in expressions Example "I am in Paris" Example "I am in Paris" propositional symbol P to denote the sentence propositional symbol P to denote the sentence predicate place describes the relationship of I and Paris: place(I, paris) predicate place describes the relationship of I and Paris: place(I, paris) predicate place(X,paris) denotes whether X is in Paris predicate place(X,paris) denotes whether X is in Paris place(I,Y) denotes whether I am at Y 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. 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. 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 S: a set of predicate calculus sentences  X ( human(X)  mortal(X) ) I: An interpretation I: An interpretationhuman(bill_gates) X: an expression logically from S X: an expression logically from Smortal(bill_gates)

Exercise 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). 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. If Cathy is a mechanic then she is not a nurse.  m(C)  ~n(C). Cathy is taller than Bob. 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. 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)  t(X, Z) ).

Some Predicate Calculus Equivalences

First Order Predicate Calculus First-order predicate calculus: universally and existentially quantified variables refer only to objects (constants), not to predicates or functions 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) valid expressions: V X likes(kin,X) and E X V Y likes(X,Y) - invalid expression: V (likes) likes(kin,ice_cream) - invalid expression: V (likes) likes(kin,ice_cream) this is valid in second order predicate calculus this is valid in second order predicate calculus

Inference Rules Ability of producing new, correct predicate calculus sentences from an original set of predicate calculus sentences 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 given: P=>Q and P are true conclusion: Q is true conclusion: Q is true Example: Example: P=>Q: “If I am in Paris then I am in France” P=>Q: “If I am in Paris then I am in France” P: “I am in Paris” P: “I am in Paris” Q: “I am in France” added to P=>Q and P Q: “I am in France” added to P=>Q and P

Inference Rules Modus Tolens: given: P=>Q is true, and Q is false given: P=>Q is true, and Q is false conclusion: P is false conclusion: P is false Example: Example: P=>Q: “If I am in Paris then I am in France” P=>Q: “If I am in Paris then I am in France” ~Q: “I am not in France” ~Q: “I am not in France” ~P: “I am not in Paris” added to P=>Q and ~Q ~P: “I am not in Paris” added to P=>Q and ~Q

Inference Rules (Resolution) Inference Rules Resolution: Resolution: given: PvQ and ~QvR are true given: PvQ and ~QvR are true conclusion: PvR is true conclusion: PvR is true Universal instantiation: given: V X p(X) is true, and constant x is from the domain of X given: V X p(X) is true, and constant x is from the domain of X conclusion: p(x) is true conclusion: p(x) is true example: all birds have feathers and a penguin is a bird example: all birds have feathers and a penguin is a bird conclusion: penguin has feathers conclusion: penguin has feathers

Unification Unification The process of finding the substitutions needed to make two predicate calculus expressions match. 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))} 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} 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))} - 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’ - 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 constant: c/X a variable may be replaced by a variable: Y/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 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 once a variable has been bound, future unification and inferences must take this substitution into account

Unification Unification is an algorithm for determining the substitutions needed to make two predicate calculus expressions match. Unification is an algorithm for determining the substitutions needed to make two predicate calculus expressions match. Unification Substitutions alpha( X, a, beta(Y) ). alpha( X, a, beta(Y) ). Is to be unified with 1. alpha( fred, a, beta(Z) ). 2. alpha( W, a, beta(jack) ). 3. 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: In this example, the unifications that would make the original expression identical to each of the other three are written as: 1. { fred / X, Z / Y } 2. { W / X, jack / Y } 3. { Z / X, beta(Z) / Y} The notation X / Y indicates that X is substituted for the variable Y. Substitutions are also called ‘bindings’. 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 1. Compose { X / Y, W / Z } with { V / X } to give { V / Y, W / Z } 2. 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. 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.

Examples Emma is a Doberman pinscher and a good dog: Emma is a Doberman pinscher and a good dog: Googdog(emma) ^ isa(emma,doberman) Googdog(emma) ^ isa(emma,doberman) every dog is an animal: every dog is an animal: V X (dog(X) => animal (X)) V X (dog(X) => animal (X)) every boy has a bicycle: every boy has a bicycle: V X (E Y (boy(X) => (bicycle(Y) ^ own(X,Y)))) V X (E Y (boy(X) => (bicycle(Y) ^ own(X,Y))))

Few More Examples….

Application: A Logic-Based Financial Advisor 1. People with inadequate savings should increase their savings, regardless of income. 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. 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. 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 4. Adequate savings is to have more than $5,000 in the bank for each dependent. dependent. 5. Adequate income is steady, more than $15,000 plus $4,000 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: 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, 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(25000,steady) ^ dependents(3) unifies with earnings(X,steady) ^ dependents(Y) earnings(X,steady) ^ dependents(Y) Under the substitutions {25000/X, 3/Y}. This substitution yields the new implication. 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, minincome(3))=>income (inadequate). earnings(25000,steady)^dependents(3)^~greater(25000, 27000)=> 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. 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) 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: 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,min savings(3))=>savings_account(adequate). amount_saved(22000)^dependents(3)^greater(22000,min savings(3))=>savings_account(adequate). Here, evaluating the function minsavings(3) yields: Here, evaluating the function minsavings(3) yields: amount_saved(22000)^dependents(3)^greater(22000,150 00)=>savings_account(adequate). amount_saved(22000)^dependents(3)^greater(22000,150 00)=>savings_account(adequate). It yields the conclusion: It yields the conclusion: 15. savings_account(adequate). So after applying Modus ponens on 14, 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). 3.savings_account(adequate)^income(inadequate) => investment (combination). This will be the suggested investment of this individual. 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. 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. 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 convert as many sentences as you can in Predicate Calculus. Try to implement Unification and unify the predicate expressions 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….. 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. 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 25 th, Due date October 25 th, Submit the code (.cpp) and (.exe) files in the in assign1_roll_number folder with your registration # as your file names cpp Submit the code (.cpp) and (.exe) files in the in assign1_roll_number folder with your registration # as your file names cpp Add as many comments as possible in your code file, so that documentation won’t be required. Add as many comments as possible in your code file, so that documentation won’t be required.