- By
**avel** - Follow User

- 459 Views
- Uploaded on

Download Presentation
## Artificial Intelligence (AI)

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

**A.I. is the Future of Computing!**Artificial Intelligence (AI) AmanUllah Khan Revised By: Ghulam Irtaza Sheikh**Text:**• Artificial Intelligence: Structures and Strategies for Complex Problem Solvingby GEORGE F LUGER • Reference: • Practical Common Lisp by Peter Seibel • Learn Prolog Now, by Patrick Blackburn, Johan Bos and Kristina Striegnitz • CLIPS User and Reference Manuals • Various resources on the Web • CS 607 (VU)**Chapter 2**Institute of Computing**Last lecture**• Quantifiers • First Order Predicate Calculus**Today**• Interpretation • Inference**Predicate of brotherhood:**{<R,J>,<J,R>} Predicate of being onHead: {<C,J>} Predicate of being a person: {J,R} Predicate of being the king: {J} Predicate of being a crown: {C} Function for left legs: <{J,JLL},{R,RLL}> Example**Interpretation**• Specifies which objects, functions, and predicates are referred to by which constant symbols, function symbols, and predicate symbols. • Under the intended interpretation: • “richardI” refers to R; “johnII” refers to J; “crown” refers to the crown. • “onHead”,”brother”,”person”,”king”, “crown”, “leftLeg”**Examples given the Sample Interpretation**• All X,Y brother(X,Y) FALSE • All X,Y (person(X) ^ person(Y)) brother(X,Y) FALSE • All X,Y (person(X) ^ person(Y) ^ ~(X=Y)) brother(X,Y) TRUE • Exists X crown(X) TRUE • Exists X Exists Y sister(X,Y) FALSE**Inference**• Logical inference – infer new correct expressions from a set of true assertions • New expressions must be consistent with all previous expressions**Satisfy, Model, Valid, Inconsistent**• If X has a value of T for all possible interpretations, X is said to valid • The expression ∃X (p(X) /\ ~p(X)) is inconsistent, because it is not satisfiable under any interpretation or variable assignment. • Whereas ∀X (p(X) \/ ~p(X)) is valid. Institute of Computing, Bahauddin Zakariya University, Multan**Proof Procedure**• A proof procedure is a combination of an inference rule and an algorithm for applying that rule to a set of logical expressions to generate new sentences. Institute of Computing, Bahauddin Zakariya University, Multan**Logically Follows, Sound and Complete**• A PC expression X logically follows from a set S of PC expressions if every interpretation and variable assignment that satisfies S also satisfy X. • An inference rule is sound if every PC expression produced by the rule from a set S of PC expressions also logically follows from S. • An inference rule is complete if, given a set S of PC expressions, the rule can infer every expression that logically follows from S. Institute of Computing, Bahauddin Zakariya University, Multan**Inference Rules**• Modus Ponens • If the sentence P and P => Q are known to be true, the modus ponens let us infer Q. • Modus Tollens: • If P => Q is known to be true and Q is known to be false, we can infer ~P. • Abduction • If P => Q and Q are known to be true, the Abduction rule, let us infer ~P. Institute of Computing, Bahauddin Zakariya University, Multan**Inference Rules**• And Elimination: • And eliminations allows us to infer the truth of either conjuncts from truth of conjunctive sentence. For example: P/\Q, let conclude P and Q are true. • And Introduction: • And introduction let us infer the truth of conjunction from the truth of its conjuncts. For instance, if P and Q are true , then P/\Q is true. • Universal instantiation: • It states that if any universally quantified variable is true sentence is replaced by appropriate term from the domain, the result is a true sentence. Thus if a is from the domain of X, then∀X p(X), let us infer p(a). Institute of Computing, Bahauddin Zakariya University, Multan**Modus Ponens Applications**• For example, if P represents “it is raining” and Q represents “the ground is wet” then the observation “if it is raining then the ground will be wet” can be represented as P=>Q. Thua our set of axioms becomes: P = >Q P • Through an application of modus ponens, the fact that “the ground is wet” (Q) may be added to the set of true expressions. • The common syllogism “all men are mortal and Socrates is a man” can be represented as: ∀X (man(X) => mortal(X)). man(scocrates). • By substituting X=socrates in the implication we infer the expression • man(scorates) =>mortal(socrates). Now the modes ponens can be applies to infer the conclusion mortal(socrates). Institute of Computing, Bahauddin Zakariya University, Multan**Dog World : Modus Ponens Applications**• All dogs are animal: ∀X (dog(X) => animal(X)). • Fido is a dog : dog(fido). • 1 for (fido/X) gives : dog(fido) => animal(fido). • Applying Modus ponens to 2& 3 gives: animal(fido). • All animals will die : ∀Y (animal(Y) => die(Y)). • 5 for (fido/Y) gives: (animal(fido) => die(fido)). • Applying Modus ponens 4&6 gives: die(fido). Institute of Computing, Bahauddin Zakariya University, Multan**Anyone passing his history exams and winning the lottery is**happy. But anyone who studies or is lucky can pass all his exams. John did not study but he is lucky. Anyone who is lucky wins the lottery. Is John happy? • Anyone passing his history exams and winning the lottery is happy : ∀X (pass(X,history) /\ win(X,lottery)) => happy(X)). • Anyone who studies or is lucky can pass all his exams: ∀X ∀Y (study(X) \/ lucky(X) => pass(X,Y)) • John did not study but he is lucky: ~study(john) /\ lucky(john). • Anyone who is lucky wins the lottery: ∀X (lucky(X) => win(X,lottery)). • Is john happy? happy(john) Institute of Computing, Bahauddin Zakariya University, Multan**∀X (pass(X,history) /\ win(X,lottery)) => happy(X)).**• ∀X ∀Y (study(X) \/ lucky(X) => pass(X,Y) • ~study(john) /\ lucky(john). • ∀X (lucky(X) => win(X,lottery)). • happy(john). : Applying “and elimination to 3 gives • ~study(john) • lucky(john) : Univ. Instantiation with (john/X) to 4 gives • lucky(john) => win(john,lottery) : Apply Modus Ponens to 7&8 gives • win(john,lottery) : Univ. Instantiation with (john/X)&(history/Y) to 2gives • study(john) \/ lucky(john) => pass(john,history) • ~(~study(john)) \/ lucky(john) => pass(john,history) : apply 6 • ~(T) \/ lucky(john) => pass(john,history) or • F \/ lucky(john) => pass(john,history) :. F \/ P = P • lucky(john) => pass(john,history) : Applying Modus Ponens to 7&10 gives • pass(john,history) : Univ. Instantiation to 1 for (john/X) gives • pass(john,history) /\ win(john,lottery)) => happy(john) : Introducing “and” to 9&11, gives • pass(john,history) /\ win(john,lottery) : Applying Modus Ponens to 12&13 gives • happy(john). : Hence the query “Is john happy ?” is true. Institute of Computing, Bahauddin Zakariya University, Multan**Exciting Life**All people who are not poor and are smart are happy. Those people who read are not stupid. John can read and is wealthy. Happy people have exciting lives. Can anyone be found with an exciting life? Assume :∀X (smart(X) ≡ stupid(X)) and ∀Y(wealthy(Y) ≡ ~poor(Y) • All people who are not poor and are smart are happy. ∀X (~poor(X) /\ smart(X) =>happy(X) • Those people who read are not stupid. ∀Y (read(Y) => smart(Y)) • John can read and is wealthy. read(john) /\ ~poor(john) • Happy people have exciting lives. ∀X (happy(Z) => exciting(Z)) • Can anyone be found with an exciting life? ∃ W (exciting(W))**Dog and Master World**• Fred is a collie. collie(fred). • Sam is Fred’s master. master(fred, sam). • It is staurday. day(saturday). • It is cold on Saturday ~warm(saturday) • Fred is a trained dog. trained(fred). • Spaniels and collies that are trained are good dogs. ∀ X [spaniel(X) \/ (collie(X) /\ trained(X)) = > gooddog(X)]. • If a dog is a good dog and has a master then he will be with his master ∀X ∀Y ∀Z [gooddog(X) /\ master(X,Y) /\ location(Y,Z) => location(X,Z)]. • If it is Saturday and warm, then sam is at park day(saturday) /\ warm(saturday) => location(sam, park). • If it is Saturday and not warm, then sam is at museum. day(saturday) /\ ~warm(saturday) => location(sam, museum).**English Grammar**Five rules for a simple subset of English grammar are: • A sentence is a nounphrase (np) followed by a verbphrase (vp): sentence npvp • A noun phrase is a noun (n): np n • A noun phrase is an article (art) followed by noun: np art n • A verb phrase is a verb (v): vp v • A verb phrase is a verb followed by a noun phrase: vp v np Institute of Computing, Bahauddin Zakariya University, Multan**Dictionary**• “a” and “the” are articles: Art a Art the • “man” and “dog” are nouns: N man N dog • “likes” and “bites” are verbs: V likes V bites Institute of Computing, Bahauddin Zakariya University, Multan**Unification**• In order to apply inference rules such as modus ponens, etc. an inference system must be able to determine when two expressions are the same or match. • Two propositional calculus expressions match if and only if they are syntactically identical. • Whereas matching two predicate calculus sentences is complicated by the existence of variables in the expressions. • Universal instantiation allows universally quantified variables to be replaced by terms from the domain. This requires a decision process for determining the variable substitutions under which two or more expressions can be made identical (usually for the purpose of applying inference rules). • Unification is an algorithm for determining the substitutions needed to make two predicate calculus expressions match. • Unification is important for any artificial intelligence problem solver that uses the predicate calculus for representation. Unification specifies conditions under which two (or more) predicate calculus expressions may be said to be equivalent. This allows use of inference rules, such as resolution, with logic representations, a process that often requires backtracking to find all possible interpretations.**Unification**• Unification -- An algorithm (procedure) for determining the substitutions needed to make two predicate calculus expressions match • Unifier -- a set of variable substitutions that make two expressions identical • E.g, for expression foo(X, a, goo(Y)) ExpressionsSubstitutions foo(fred, a, goo(Z)) {fred/X, Z/Y} foo(W, a, goo(jack)) {W/X, jack/Y} foo(Z, a, goo(moo(Z))) {Z/X, moo(Z)/Y}**Unification Issues**• can be simply removed • may be eliminated by replacing the variable with the constant. E.g. Xparent(X, tom) parent(mary, tom) • Skolem function may be used to replace a variable that depends on other variables e.g. XYparent(X,Y) parent(X,f(X)) • A variable may be replaced by any terms, but not the terms that contain it • A constant cannot be replaced by any terms • If a variable is bound to a constant, it my not be re-bound**Unify function**function unify(E1, E2); begin case both E1 and E2 are constants or the empty list: if E1 = E2 then return {} else return FAIL; E1 is a variable: if E1 occurs in E2 then return FAIL else return {E2/E1}; E2 is a variable: if E2 occurs in E1 then return FAIL else return (E1/E2} either E1 or E2 are empty then return FAIL otherwise: begin HE1 := first element of E1; HE2 := first element of E2; SUBS1 := unify(HE1 ,HE2); if SUBS1 : = FAIL then return FAIL; TE1:= apply(SUBS1, rest of E1); TE2 := apply (SUBS1, rest of E2); SUBS2 := unify(TE1, TE2); if SUBS2 = FAIL then return FAIL; else return composition(SUBS1 ,SUBS2) end end end. Institute of Computing, Bahauddin Zakariya University, Multan**A Unification Example**• How, unify algorithm works, may be clarified by tracing the call unify((parents X (father X) (mother bill)), (parents bill (father bill) Y)) • When unify is first called, because neither argument is an atomic symbol, the function will attempt to recursively unify the first elements of each expression, calling unify(parents, parents) • This unification succeeds, returning the empty substitution, { }. Applying this to the remainder of the expressions creates no change; the algorithm then calls unify((X (father X) (mother bill)), (bill (father bill) Y)). • The tree depiction of the execution at this stage appears in Figure 2.4. Institute of Computing, Bahauddin Zakariya University, Multan**A Unification Example (1)**Institute of Computing, Bahauddin Zakariya University, Multan**A Unification Example (2)**• In the second call to unify, neither expression is atomic, so the algorithm separates each expression into its first component and the remainder of the expression. This leads to the call unify(X, bill). • This call succeeds, because both expressions are atomic and one of them is a variable. The call returns the substitution (bill/X). This substitution is applied to the remainder of each expression and unify is called on the results, as in Figure 2.5: unify(((father bill) (mother bill)), ((father bill)Y)). Institute of Computing, Bahauddin Zakariya University, Multan**A Unification Example (3)**Institute of Computing, Bahauddin Zakariya University, Multan**A Unification Example (4)**• The result of this call is to unify (father bill) with (father bill). This leads to the calls unify(father, father) unify(bill, bill) unify(( ), ( )) • All of these succeed, returning the empty set of substitutions as seen in Figure 2.6. • Unify is then called on the remainder of the expressions: unify(((mother bill)), (Y)). This, in tum, leads to calls unify((mother bill), Y) unify(( ),( )). • In the first of these, (mother bill) unifies with Y. Notice that unification substitutes the whole structure (mother bill) for the variable Y. Thus, unification succeeds and returns the substitution ((mother bill)/Y). The call unify(( ),( )) • returns { }. These are composed, along with the earlier substitution {bill/X}, to return the answer {bill/X (mother bill)/Y). A trace of the entire execution appears in Figure 2.6. Each can is numbered to indicate the order in which it was made; the substitutions returned by each call are noted on the arcs of the tree. Institute of Computing, Bahauddin Zakariya University, Multan**A Unification Example (5)**Institute of Computing, Bahauddin Zakariya University, Multan**Summary**• Propositional Calculus • Declarative, Partial/Disjunctive Information • Limited expressiveness • Predicate Calculus • Objects, Properties & Relations • Variables & Quantification • Inference Rules • Avoid exhaustive model checking • Unification & Modus Ponens • Application: A Logic Based Financial Advisor

Download Presentation

Connecting to Server..