Representing Knowledge Using Rules INT 404 1 Natural

  • Slides: 38
Download presentation
Representing Knowledge Using Rules INT 404 1

Representing Knowledge Using Rules INT 404 1

Natural Deduction üLimitations of Resolution ( Evolution of Natural Deduction) ü The previous method

Natural Deduction üLimitations of Resolution ( Evolution of Natural Deduction) ü The previous method of resolution brings uniformity, everything looks the same. Hence at times, it becomes very difficult to pick the statement that may be useful in solving the problem. üAs we convert everything into clause form, we loose important heuristic information. üEg. We believe that all judges who are not crooked are well-educated ü¥x : judge(x) À ¬ crooked (x) educated(x) üIn the clause form it will take the following shape ü¬ judge (x) V crooked(x) V educated(x) 2

Natural Deduction ü Another problem with the use of resolution is that people do

Natural Deduction ü Another problem with the use of resolution is that people do not think in resolution. üComputers are still poor at proving very hard things, hence we need a practical standpoint. ( focus is on interaction) üTo facilitate it we led to Natural Deduction. üIt describes a blend of techniques, used in combination to solve problems that are not traceable by any one method alone. üOne common technique is to talk about objects involved in the predicate and not the predicate itself. 3

Truth Table Modus Ponens 5/22/2021 4

Truth Table Modus Ponens 5/22/2021 4

Some Rules of Inference 5/22/2021 5

Some Rules of Inference 5/22/2021 5

Rules of Inference 5/22/2021 6

Rules of Inference 5/22/2021 6

Procedural v/s Declarative Knowledge üA Declarative representation is one in which knowledge is specified

Procedural v/s Declarative Knowledge üA Declarative representation is one in which knowledge is specified but the use to which that knowledge is to be put in, is not given. üA Procedural representation is one in which the control information that is necessary to use the knowledge is considered to be embedded in the knowledge itself. üTo use a procedural representation, we need to augment it with an interpreter that follows the instructions given in the knowledge. üThe difference between the declarative and the procedural views of knowledge lies in where control information resides. 7

üProcedural v/s Declarative Knowledge üConsider the example üman(Marcus) üman (Ceaser) üPerson(Cleopatra) üVx : man(x)

üProcedural v/s Declarative Knowledge üConsider the example üman(Marcus) üman (Ceaser) üPerson(Cleopatra) üVx : man(x) person(x) üNow we want to extract from this knowledge base the ans to the question : üƎy : person (y) üMarcus, Ceaser and Cleopatra can be the answers 8

üProcedural v/s Declarative Knowledge üAs there is more than one value that satisfies the

üProcedural v/s Declarative Knowledge üAs there is more than one value that satisfies the predicate, but only one value is needed, the answer depends on the order in which the assertions are examined during the search of a response. üIf we view the assertions as declarative, then we cannot depict how they will be examined. If we view them as procedural, then they do. üLet us view these assertions as a non deterministic program whose output is simply not defined, now this means that there is no difference between Procedural & Declarative Statements. But most of the machines don’t do so, they hold on to what ever method they have, either sequential or in parallel. üThe focus is on working on the control model. 9

üProcedural v/s Declarative Knowledge üman(Marcus) üman (Ceaser) üVx : man(x) person(x) üPerson(Cleopatra) üIf we

üProcedural v/s Declarative Knowledge üman(Marcus) üman (Ceaser) üVx : man(x) person(x) üPerson(Cleopatra) üIf we view this as declarative then there is no difference with the previous statement. But viewed procedurally, and using the control model, we used to got Cleopatra as the answer, now the answer is marcus. üThe answer can vary by changing the way the interpreter works. üThe distinction between the two forms is often very fuzzy. Rather then trying to prove which technique is better, what we should do is to figure out what the ways in which rule formalisms and interpreters can be combined to solve problems. 10

Logic Programming üLogic programming is a programming language paradigm in which logical assertions are

Logic Programming üLogic programming is a programming language paradigm in which logical assertions are viewed as programs, e. g : PROLOG üA PROLOG program is described as a series of logical assertions, each of which is a Horn Clause. üA Horn Clause is a clause that has at most one positive literal. üEg p, ¬ p V q etc are also Horn Clauses. üThe fact that PROLOG programs are composed only of Horn Clauses and not of arbitrary logical expressions has two important consequences. üBecause of uniform representation a simple & effective interpreter can be written. üThe logic of Horn Clause systems is decidable. 11

A Declarative and a Procedural Representation 12 144

A Declarative and a Procedural Representation 12 144

Answering Questions in PROLOG 13 145

Answering Questions in PROLOG 13 145

Logic Programming üEven PROLOG works on backward reasoning. üThe program is read top to

Logic Programming üEven PROLOG works on backward reasoning. üThe program is read top to bottom, left to right and search is performed depth-first with backtracking. üThere are some syntactic difference between the logic and the PROLOG representations as mentioned in Fig 6. 1 üThe key difference between the logic & PROLOG representation is that PROLOG interpreter has a fixed control strategy, so assertions in the PROLOG program define a particular search path to answer any question. Where as Logical assertions define set of answers that they justify, there can be more than one answers, it can be forward or backward tracking. 14

Logic Programming üControl Strategy for PROLOG states that we begin with a problem statement,

Logic Programming üControl Strategy for PROLOG states that we begin with a problem statement, which is viewed as a goal to be proved. üLook for the assertions that can prove the goal. üTo decide whether a fact or a rule can be applied to the current problem, invoke a standard unification procedure. üReason backward from that goal until a path is found that terminates with assertions in the program. üConsider paths using a depth-first search strategy and use backtracking. üPropagate to the answer by satisfying the conditions. 15

Forward v/s Backward Reasoning üThe objective of any search is to find a path

Forward v/s Backward Reasoning üThe objective of any search is to find a path through a problem space from the initial to the final one. üThere are 2 directions to go and find the answer üForward üBackward ü 8 -square problem üReason forward from the initial states : Begin building a tree of move sequences that might be solution by starting with the initial configuration(s) at the root of the tree. Generate the next level of tree by finding all the rules whose left sides match the root node and use the right sides to create the new configurations. Generate each node by taking each node generated at the previous level and applying to it all of the rules whose left sides match it. Continue. 16

Forward v/s Backward Reasoning üReason backward from the goal states : Begin building a

Forward v/s Backward Reasoning üReason backward from the goal states : Begin building a tree of move sequences that might be solution by starting with the goal configuration(s) at the root of the tree. Generate the next level of tree by finding all the rules whose right sides match the root node and use the left sides to create the new configurations. Generate each node by taking each node generated at the previous level and applying to it all of the rules whose right sides match it. Continue. This is also called Goal-Directed Reasoning. üTo summarize, to reason forward, the left sides(pre conditions) are matched against the current state and the right sides(the results) are used to generate new nodes until the goal is reached. üTo reason backwards, the right sides are matched against the current node and the left sides are used to generate new nodes. 17

A Sample of the Rules for Solving the 8 -Puzzle . . . An

A Sample of the Rules for Solving the 8 -Puzzle . . . An Examples : Start Goal 18 146

üForward v/s Backward Reasoning üFactors that influence whether to choose forward or backward reasoning

üForward v/s Backward Reasoning üFactors that influence whether to choose forward or backward reasoning : üAre there more possible start states or goal states? We would like to go from smaller set of states to larger set of states. üIn which direction is the branching factor (the average number of nodes that can be reached directly from a single node) greater? We would like to proceed in the direction with the lower branching factor. üWill the program be asked to justify its reasoning process to the user? It so, it is important to proceed in the direction that corresponds more closely with the way user will think. üWhat kind of event is going to trigger a problem-solving episode? If it is the arrival of a new fact , forward reasoning should be used. If it a query to which response is desired, use backward reasoning. 19

Forward v/s Backward Reasoning üHome to unknown place example. üMYCIN üBidirectional Search ( The

Forward v/s Backward Reasoning üHome to unknown place example. üMYCIN üBidirectional Search ( The two searches must pass each other) üForward Rules : which encode knowledge about how to respond to certain input configurations. üBackward Rules : which encode knowledge about how to achieve particular goals. 20

Forward v/s Backward Reasoning üBackward-Chaining Rule Systems üPROLOG & MYCIN is an example of

Forward v/s Backward Reasoning üBackward-Chaining Rule Systems üPROLOG & MYCIN is an example of this. üThese are good for goal-directed problem solving. üForward –Chaining Rule Systems üWe work on the incoming data here. üThe left sides of rules are matched with against the state description. üThe rules that match the state dump their right side assertions into the state. üMatching is more complex forward chaining systems than backward ones. üOPS 5 is the examples of the same. 21

üCombining Forward v/s Backward Reasoning üPatients example of diagnosis. üIn some systems , this

üCombining Forward v/s Backward Reasoning üPatients example of diagnosis. üIn some systems , this is only possible in reversible rules. 22

MATCHING üMatching üTill now we have used search to solve the problems as the

MATCHING üMatching üTill now we have used search to solve the problems as the application of appropriate rules. ü We applied them to individual problem states to generate new states to which the rules can then be applied, until a solution is found. üWe suggest that a clever search involves choosing from among the rules that can be applied at a particular point, but we do not talk about how to extract from the entire collection of rules those that can be applied at a given point. üTo do this we need matching. 23

MATCHING üIndexing üDo a simple search through all the rules, comparing each one’s precondition

MATCHING üIndexing üDo a simple search through all the rules, comparing each one’s precondition to the current state and extracting all the ones that match. üBut this has two problems üIn order to solve very interesting problems , it will be necessary to use a large number of rules, scanning through all of them at every step of the search would be hopelessly inefficient. üIt is not always immediately obvious whether a rule’s preconditions are satisfied by a particular state. üTo solve the first problem, use simple indexing. Eg. In Chess , combine all moves at a particular board state together. 24

Representation Affects Matching 25 149

Representation Affects Matching 25 149

MATCHING üMatching with Variables üThe problem of selecting applicable rules is made more difficult

MATCHING üMatching with Variables üThe problem of selecting applicable rules is made more difficult when preconditions are not stated as exact descriptions of particular situations but rather describe properties that the situations must have. üThen we need to match a particular situation and the preconditions of a given situation. üIn many rules based systems, we need to compute the whole set of rules that match the current state description. Backward Chaining Systems usually use depth-first backtracking to select individual rules, but forward chaining systems use Conflict Resolution Strategies. üOne efficient many to many match algorithm is RETE 26

Many to Many Matching v The temporal nature of data. Rules usually do not

Many to Many Matching v The temporal nature of data. Rules usually do not alter the state description radically. Instead, a rule will typically add one or two element or delete one or two, but most of the state description remain same. v Structural similarity in rules. Different rules may share large number of preconditions. v Persistence of variable binding consistency. When all individual preconditions of the rule might be met, there may be variable binding conflicts that prevent the rule from firing. Given son(Mary, Joe) and son(Bill, Bob). 27 150

MATCHING üComplex & Approximate Matching üA more complex matching process is required when the

MATCHING üComplex & Approximate Matching üA more complex matching process is required when the preconditions of a rule specify required properties that are not stated explicitly in the description of the current state. In this case, a separate set of rules must be used to describe how some properties can be inferred from others. üAn even more complex matching process is required if rules should be applied if their preconditions approximately match the current situation. Example of listening to a recording of a telephonic conversation. üFor some problems, almost all the action is in the matching of the rules to the problem state. Once that is done, so few rules apply that the remaining search is trivial. Example ELIZA 28

A Bit of a Dialogue with ELIZA 29 151

A Bit of a Dialogue with ELIZA 29 151

Some ELIZA-like rules My brother is mean to me. Eliza Response: Who else in

Some ELIZA-like rules My brother is mean to me. Eliza Response: Who else in your family is mean to you? Or Tell me more about family. 30 152

Conflict Resolution üThe result of the matching process is a list of rules whose

Conflict Resolution üThe result of the matching process is a list of rules whose antecedents have matched the current state description along with whatever variable binding were generated by the matching process. üIt is the job of the search method to decide on the order in which the rules will be applied. But sometimes it is useful to incorporate some of the decision making into the matching process. This phase is called conflict resolution. üThere are three basic approaches to the problem of conflict resolution in the production system üAssign a preference based on the rule that matched. üAssign a preference based on the objects that matched. üAssign a preference based on the action that the matched rule would perform.

Conflict Resolution v Preferences based on rules. - Rule order. E. g. PROLOG -

Conflict Resolution v Preferences based on rules. - Rule order. E. g. PROLOG - Prefer special cases over more general ones. - There are two to decide which rule is general. - If the set of preconditions of one rule contain all the preconditions of another(plus some others), then second rule is more general than first. - If the set of preconditions of one rule are same as those of another except that in first case variables are specified and in second there are constants, then first rule is more general than second. v Preferences based on objects. - Prefer some objects to others. - If input sentence contained variety of keywords that ELIZA knew. If that happened, then ELIZA made use of the fact that some keywords had been marked as being more significant then another. P: I know everybody laughed at me. ELIZA: You say you know everybody laughed at you. Or, Who in particular are you thinking of? v Preferences based on states. - Heuristic 153

Control Knowledge • Intelligent program require search, search is computationally intractable unless it is

Control Knowledge • Intelligent program require search, search is computationally intractable unless it is constrained by knowledge about the world. • Knowledge about which paths are more likely to lead quickly to goal state is often called search controlled knowledge. It can make many forms: 1. Knowledge about which states are more preferable to others. 2. Knowledge about which rule to apply in a given situation. 3. Knowledge about the order in which to pursue subgoals. 4. Knowledge about useful sequences of rules to apply. 33

Control Knowledge • A number of AI systems represent their control knowledge with rules.

Control Knowledge • A number of AI systems represent their control knowledge with rules. • SOAR: is a general architecture for building intelligent system. SOAR is based on set of specific, cognitively motivated hypotheses about the structure of human problem solving. In SOAR: 1. Long-Term Memory is stored as a set of productions (or rules). 2. Short-Term Memory (also called working memory) is a buffer is analogues to the state description in problem solving. 3. All problem-solving activity takes place as a state space traversal. 4. All intermediate and final results of problem solving are remembered (or, chunked) for further reference. 34

Control Knowledge 35

Control Knowledge 35

Question-1 36

Question-1 36

Question-2 37

Question-2 37

Thank You!!! 38

Thank You!!! 38