ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and...

68
ARTIFICIAL INTELLIGENCE Lecture 5 Networks and Communication Department 1 By: Latifa ALrashed

Transcript of ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and...

Page 1: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

ARTIFICIAL INTELLIGENCE

Lecture 5 Networks and Communication Department

1

By: Latifa ALrashed

Page 2: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Outline

Networks and Communication Department

q  Define and give a brief history of artificial intelligence.

q  Describe how knowledge is represented in an intelligent agent.

q  Semantic network

q  Frames

q  Predicate logic

q  Rule-based system

q  Show how expert systems can be used when a human expert is not available.

q  Show how an artificial agent can be used to simulate mundane tasks performed by human beings.

q  Show how expert systems and mundane systems can use different search techniques to solve problems.

Page 3: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

What is Artificial Intelligence?

Networks and Communication Department

Page 4: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

What is Artificial Intelligence ?

Networks and Communication Department

Page 5: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

A brief history of artificial intelligence

Networks and Communication Department

Page 6: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Artificial Intelligence History

Networks and Communication Department

•  Although artificial intelligence as an independent field of study is relatively new, it has some roots in the past.

•  We can say that it started 2,400 years ago when the Greek

philosopher Aristotle invented the concept of logical reasoning.

•  The effort to finalize the language of logic continued with

Leibniz and Newton.

Page 7: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Artificial Intelligence History (Cont.)

Networks and Communication Department

•  George Boole developed Boolean algebra in the nineteenth century that laid the foundation of computer circuits.

•  However, the main idea of a thinking machine came from Alan Turing, who proposed the Turing test. The term “artificial intelligence” was first coined by John McCarthy in 1956.

Page 8: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

The Turing Test

Networks and Communication Department

•  In 1950, Alan Turing proposed the Turing test, which provides a definition of intelligence in a machine.

•  The test simply compares the intelligent behavior of a human being with that of a computer.

•  An interrogator asks a set of questions that are forwarded to both a computer and a human being.

•  The interrogator receives two sets of responses, but does not know which set comes from the human and which set from the computer.

•  After careful examination of the two sets, if the interrogator cannot definitely tell which set has come from the computer and which from the human, the computer has passed the Turing test for intelligent behavior.

Page 9: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Intelligent agents

•  An intelligent agent is a system that perceives its environment, learns from it, and interacts with it intelligently.

•  Intelligent agents can be divided into two broad categories: software agents and physical agents.

Page 10: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Intelligent agents

Networks and Communication Department

Agents  interact  with  environments  through    sensors  and  actuators.  

Page 11: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Intelligent agents – Software agent

A software agent is a set of programs that are designed to do particular tasks. For example, a software agent can check the contents of received e-mails and classify them into different categories (junk, less important, important, very important and so on). Another example of a software agent is a search engine used to search the World Wide Web and find sites that can provide information about a requested subject.

Software agents

Page 12: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Intelligent agents – Physical agent

•  A physical agent (robot) is a programmable system that can be used to perform a variety of tasks.

•  Simple robots can be used in manufacturing to do routine jobs such as assembling, welding, or painting.

•  Mobile robots are used underwater to prospect for oil. •  A humanoid robot is an autonomous mobile robot that is

supposed to behave like a human.

Physical agents

Page 13: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Programming Languages

Networks and Communication Department

Although some all-purpose languages such as C, C++ and Java are used to create intelligent software, two languages are specifically designed for AI: LISP and PROLOG.

Page 14: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Programming Languages (Cont.)

Networks and Communication Department

¨  LISP §  LISP (derives from LISt Programming) was

invented by John McCarthy in 1958. §  As the name implies, LISP is a programming

language that manipulates lists. §  It treats data as well as program as lists, which

means that a LISP program can change itself §  It is slow if the list to be handled is long §  Complexity of its syntax

Page 15: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Programming Languages

Networks and Communication Department

PROLOG

•  PROLOG (PROgramming in LOGic) is a language that can build a database of facts and a knowledge base of rules. •  A program in PROLOG can use logical reasoning to answer questions that can be inferred from the knowledge base. •  However, it is not a very efficient programming language

Page 16: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Knowledge Representation

Networks and Communication Department

Page 17: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Knowledge Representation

Networks and Communication Department

•  If an artificial agent is supposed to solve some problems related to the real world, it somehow

needs to be able to represent knowledge. •  Facts are represented as data structures that

can be manipulated by programs stored inside the computer.

•  In this section, we describe four common methods for representing knowledge: semantic networks, frames, predicate logic and rule-based systems.

Page 18: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Semantic Representation

Networks and Communication Department

¨  A semantic network uses directed graphs to represent knowledge. A directed graph is made of vertices (nodes) and edges (arcs).

¨  In a directed graph each edge, which connect two vertices, has a direction ( shown in the figure by an arrowhead).

¨  Semantic networks uses vertices to represent concepts and edges (denoted by arrows) to represent the relation between two concepts

Page 19: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Semantic Representation (Cont.)

Figure 18.1 A simple semantic network

Page 20: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Semantic Representation (Cont.)

Networks and Communication Department

Concepts ¨  The definition of the concepts is related to the

theory of sets. ¨  A concept can be thought of as a set or a subset. ¨  For example, animal defines the set of all

animals, horse defines the set of all horses and is a subset of the set animal

¨  An object is a member (instance) of a set. ¨  Concepts are shown by vertices.

Page 21: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Semantic Representation (Cont.)

Networks and Communication Department

Relations ¨  In a semantic network, relations are shown by edges. ¨  An edge can define:

¤  a subclass relation, the edge is directed from the subclass to its superclass.

¤  an instance relation, the edge is directed from the instance to the set to which it belongs.

¤  an attribute of an object (color, size, …), ¤  or a property of an object (i.e. possessing another object)

¨  One of the most important relations that can be well defined in a semantic networks is inheritance.

¨  This can be used to infer new knowledge from the knowledge represented by the graph.

Page 22: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Frames

Networks and Communication Department

q  Frames are closely related to semantic networks.

q  In frames, data structures (records) are used to represent the same knowledge.

q  One advantage of frames over semantic networks is that programs can handle frames more easily than semantic networks.

Page 23: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Frames

Figure 18.2 A set of frames representing the semantic network in Figure 18.1

Page 24: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Frames

A node in a semantic network becomes an object in a set of frames, so an object can define a class, a subclass or an instance of a class. In Figure 18.2, reptile, mammal, dog, Roxy and Ringo are objects.

Objects

Edges in semantic networks are translated into slots—fields in the data structure. The name of the slot defines the type of the relationship and the value of the slot completes the relationship. In Figure 18.2, for example, animal is a slot in the reptile object.

Slots

Page 25: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Frames -Exercise (1)

¨  Represent the following as a set of frames The aorta is a particular kind of artery which has a

diameter of 2.5cm. An artery is a kind of blood vessel. An artery always has a muscular wall, and generally has a diameter of 0.4cm. A vein is a kind of blood vessel, but has a fibrous wall. Blood vessels all have tubular form and contain blood.

Page 26: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

26/46

Exercise 1 (solution)

Blood vessel: form: tubular contain: blood

Artery: subclass: Blood vessel wall_type: muscular diameter: 0.4cm

Vein: subclass: Blood vessel wall_type: fibrous

Aorta: subclass: Artery diameter: 2.5cm

Page 27: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Semantic Representation for exercise 1

Networks and Communication Department

Blood vessel Tubular

Artery Vein

Aorta

Subclass Subclass

Subclass

Form Blood Contain

Fibrous

Wall-type

Muscular

0.4 cm

Wall-type

Diameter

2.5 cm

Diameter

Page 28: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Predicate Logic

•  The most common knowledge representation is predicate logic.

•  Predicate logic can be used to represent complex facts. •  It is a well-defined language developed via a long history

of theoretical logic. •  Although this section defines predicate logic, we first

introduce propositional logic, a simpler language. •  We then discuss predicate logic, which employs

propositional logic.

Page 29: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic

Networks and Communication Department

¨  Propositional logic is a language made up from a set of sentences that can be used to carry out logical reasoning about the world.

¨  Propositional Logic is concerned with propositions and their interrelationships.

¨  a proposition is a possible condition of the world about which we want to say something.

¨  The condition need not be true in order for us to talk about it.

¨  In fact, we might want to say that it is false or that it is true if some other proposition is true.

Page 30: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic- syntax

Networks and Communication Department

¨  In Propositional Logic, there are two types of sentences.

¨  Simple sentences and compound (Complex) sentences.

¨  Simple sentences: ¤ It express ``atomic'' propositions about the world. ¤ Simple sentences in Propositional Logic are often

called propositional constants or, sometimes, logical constants.

Page 31: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic- syntax (Cont.)

Networks and Communication Department

¨  Compound sentences: ¤ It express logical relationships between the simpler

sentences of which they are composed. ¤ The logical value (true or false) of each sentence

depends on the logical value of the atomic sentences of which the compound sentence is made.

¤ The constituent sentences within any compound sentence can be either simple sentences or compound sentences or a mixture of the two

Page 32: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic- operators

Networks and Communication Department

¨  Propositional logic uses five operators.

¨  The first operator is unary and the other four operators are binary.

Figure 18.3 Truth table for five operators in propositional logic

Page 33: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic – sentence

Networks and Communication Department

¨  There are six types of compound sentences, negations, conjunctions, disjunctions, implications, reductions, and equivalences.

¨  A negation consists of the negation operator ¬ and a simple or compound sentence, called the target. ¤ For example, given the sentence P, we can form the

negation of P as ¬P

Page 34: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic – sentence (Cont.)

Networks and Communication Department

¨  A conjunction is a sequence of sentences separated by occurrences of the ∧ operator and enclosed in parentheses. ¤  The constituent sentences are called conjuncts. ¤  For example, we can form the conjunction of P and Q as

(P ∧ Q) ¨  A disjunction is a sequence of sentences separated by

occurrences of the ∨ operator and enclosed in parentheses. ¤  The constituent sentences are called disjuncts. ¤  For example, we can form the disjunction of P and Q as

(P ∨ Q)

Page 35: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic – sentence (Cont.)

Networks and Communication Department

¨  An implication consists of a pair of sentences separated by the ⇒ operator and enclosed in parentheses. ¤  The sentence to the left of the operator is called the

antecedent, and the sentence to the right is called the consequent.

¤  The implication of P and Q is shown below. (P ⇒ Q) ¨  A reduction is the reverse of an implication. It consists

of a pair of sentences separated by the ⇐ operator and enclosed in parentheses. ¤  The sentence to the left of the operator is called the

consequent, and the sentence to the right is called the antecedent.

¤  The reduction of P to Q is shown below. (P ⇐ Q)

Page 36: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic – sentence (Cont.)

Networks and Communication Department

¨  An equivalence is a combination of an implication and a reduction.

¨  For example, we can express the equivalence of P and Q as (P ⇔ Q)

Page 37: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic – sentence (Cont.)

A sentence in this language is defined recursively as shown below: 1.  An uppercase letter, such as A, B, S or T, that represents a

statement in a natural languages, is a sentence.

2.  Any of the two constant values (true and false) is a sentence.

3.  If P is a sentence, then ¬P is a sentence.

4.  If P and Q are sentences, then P ∨ Q, P ∧ Q, P → Q and P ↔ Q are sentences.

Page 38: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Propositional Logic

Example 18.1

The following are sentences in propositional language:

a.  Today is Sunday (S). b.  It is raining (R). c.  Today is Sunday or Monday (S ∨ M). d.  It is not raining (¬ R). e.  If a dog is a mammal then a cat is a mammal (D → C).

Page 39: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Deduction (Cont.)

Networks and Communication Department

¨  In AI we need to create new facts from the existing facts.

¨  In propositional logic, the process is called deduction.

¨  Given two presumably true sentences, we can deduce a new true sentence.

¨  The first two sentences are called premises, the deduced sentence is called the conclusion.

¨  The whole is called an argument.

Page 40: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Deduction (Cont.)

For example 1:

If we use H for “he is at home”, O for “he is at office” and the symbol |– for the “therefore”, then we can show the above argument as:

The question is how we can prove if a deductive argument is valid?!

Page 41: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Deduction (Cont.)

•  One way to find if an argument is valid is to create a truth table for the premisses and the conclusion.

•  A conclusion is invalid if we can find a counterexample case: a case in which both premisses are true, but the conclusion is false.

An argument is valid if no counterexample can be found.

Page 42: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Deduction (Cont.)

Example 1

The validity of the argument {H ∨ O, ¬H} |− O can be proved using the following truth table:

The only row to be checked is the second row. This row does not show a counterexample, so the argument is valid.

Page 43: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Deduction (Cont.)

For example 2:

We can show the above argument as { R → C,C} |– R, in which R means “She is rich”, and C means “She has a car” and the symbol |– for the “therefore”.

If  she  is  rich,  she  has  a  car.                                            Premise1:  She  has  a  car                                                                                          Premise2:  Therefore,  she  is  rich.                                                          Conclusion    

Page 44: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Deduction (Cont.)

Example 2 The argument {R → C, C} |− R is not valid because a counter example can be found:

Here row 2 and row 4 need to be checked. Although row 4 is ok, row 2 shows a counterexample (two true premisses result in a false conclusion). The argument is therefore invalid.

Page 45: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Predicate Logic

In propositional logic, a symbol that represents a sentence is atomic: it cannot be broken up to find information about its components. For example, consider the sentences:

We can combine these two sentences in many ways to create other sentences, but we cannot extract any relation between Linda and Anne. For example, we cannot infer from the above two sentences that Linda is the grandmother of Anne. To do so, we need predicate logic: the logic that defines the relation between the parts in a proposition.

Page 46: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Predicate Logic (Cont.)

In predicate logic, a sentence is divided into a predicate and arguments. For example, each of the following propositions can be written as predicates with two arguments:

The relationship of motherhood in each of the above sentences is defined by the predicate mother. If the object Mary in both sentences refers to the same person, we can infer a new relation between Linda and Anne:

grandmother (Linda, Anne)

Page 47: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Predicate Logic – sentence

Networks and Communication Department

¨  A sentence in predicate language is defined as follows: 1.  A predicate with n arguments is a sentence. Each argument can be:

¤  A constant, such as human, animal, John, Mary.

¤  A variable, such as x, y and z,

¤  A function that return an object that can takes the place of an argument

2.  Any of the two constant values (true and false) is a sentence.

3.  If P is a sentence, then ¬P is a sentence.

4.  If P and Q are sentences, then P ∧ Q, P ∨ Q, P→Q, andP ↔ Q are sentences.

Page 48: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Predicate Logic

Example 18.4

1.  The sentence “John works for Ann’s sister” can be written as: Works [John, sister(Ann)] in which the function sister(Ann) is used as an argument.

2.  The sentence “John’s father loves Ann’s sister” can be written as: loves[father(John), sister(Ann)]

Page 49: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Predicate Logic – quantifiers

Predicate logic allows us to use quantifiers. Two quantifiers are common in predicate logic:

1.  The first, which is read as “for all”, is called the universal quantifier: it states that something is true for every object that its variable represents.

2.  The second, which is read as “there exists”, is called the existential quantifier: it states that something is true for one or more objects that its variable represents.

Page 50: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Predicate Logic

Example 18.5

1. The sentence “All men are mortals” can be written as:

2. The sentence “Frogs are green” can be written as:

3. The sentence “Some flowers are red” can be written as:

Page 51: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Predicate Logic

Example 18.5

4. The sentence “John has a book” can be written as:

5. The sentence “No frog is yellow” can be written as:

Continued

or

Page 52: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Deduction

In predicate logic, if there is no quantifier, the verification of an argument is the same as that which we discussed in propositional logic. However, the verification becomes more complicated if there are quantifiers. For example, the following argument is completely valid.

Verification of this simple argument is not difficult. We can write this argument as shown next:

Page 53: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Deduction

Since the first premise talks about all men, we can replace one instance of the class man (Socrates) in that premise to get the following argument:

Which is reduced to M1 → M2, M1 |− M2, in which M1 is man(Socrates) and M2 is mortal(Socrates). The result is an argument in propositional logic and can be easily validated.

Page 54: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Beyond Predicate Logic

•  There have been further developments in logic to include the need for logical reasoning.

•  Some examples of these include high-order logic, default logic, modal logic and temporal logic.

Page 55: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems

Networks and Communication Department

¨  A rule-based system represents knowledge using a set of rules that can be used to deduce new fact from known facts.

¨  The rules express what is true if specific conditions are met. ¨  A rule-based database is a set of if… then statements in the

form

¨  In which A is called the antecedent and B is called the

consequent ¨  Each rule is handled independently without any connection

to other rules.

 if  A  then  B      or          A  →  B  

Page 56: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems - Components

A rule-based system is made up of three components: an interpreter (or inference engine), a knowledge base and a fact database, as shown in Figure 18.4.

Figure 18.4 The components of a rule-based system

Page 57: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems – Components (Cont.)

Networks and Communication Department

¨  knowledge base ¤ it is the base component in a rule-based system is a

database (repository) of rules. ¤ It contains a set of pre-established rules that can be

used to draw conclusions from the given facts. ¨  Database of fact

¤ The database of facts contains a set of conditions that are used by the rules in the knowledge base.

Page 58: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems – Components (Cont.)

Networks and Communication Department

¨  Interpreter ¤ The interpreter (inference engine) is a processor or

controller – a program, For example, that combines rules and facts.

¤ Interpreters are of two types: forward chaining and backward chaining.

Page 59: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems – Forward Chaining

Networks and Communication Department

¨  Forward chaining is a process in which an interpreter uses a set of rules and a set of facts to perform an action.

¨  The action can be just adding a new fact to the base of facts, or issuing some commands, such as start another program or a machine.

¨  The interpreter interprets and executes rules until no more rules can be interpreted.

Page 60: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems – Forward Chaining

Figure 18.5 Flow diagram for forward chaining

Page 61: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems – Forward Chaining

Networks and Communication Department

¨  If there is any conflict in which two different rules can be applied to one fact or one rule can be applied to two facts,

¨  The system needs to call a conflict resolution procedure to solve the problem.

¨  This guarantees that only one of the outputs should be added to the database of facts or only one action should be taken.

Page 62: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

A typical Forward Chaining example

Networks and Communication Department

R1: IF hot AND smoky THEN ADD fire R2: IF alarm_beeps THEN ADD smoky R3: If fire THEN ADD switch_on_sprinklers F1: alarm_beeps [Given] F2: hot [Given] F3: smoky [from F1 by R2] F4: fire [from F2, F3 by R1] F5: switch_on_sprinklers [from F4 by R3]

Page 63: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems – Backward Chaining

Forward chaining is not very efficient if the system tries to prove a conclusion. In this case, it may be more efficient if backward chaining is used.

Figure 18.6 Flow diagram for backward chaining

Page 64: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Backward Chaining Algorithm

Networks and Communication Department

To prove goal G: Ø If G is in the initial facts, it is proven. Ø Otherwise, find a rule which can be used to conclude G, and try to prove each of that rule’s conditions.

Page 65: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Rule-based Systems – Backward Chaining

Networks and Communication Department

¨  The process starts with the conclusion (goal) ¨  If the goal is already in the fact database, the

process stops and the conclusion is proved. ¨  If the goal is not in the fact database, the system

finds the rule that has the goal in its conclusion. ¨  However, instead of firing that rule, backward

chaining is now applied to each fact in the rule (recursion).

¨  If all of the facts in the rule are found in the database fact, the original goal is proved.

Page 66: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Backward Chaining Example

Networks and Communication Department

Rules: R1: IF hot AND smoky THEN fire R2: IF alarm_beeps THEN smoky R3: If fire THEN switch_on_sprinklers Facts: F1: hot F2: alarm_beeps Goal: Should I switch sprinklers on?

Page 67: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

Networks and Communication Department

67 A

ny Q

uest

ions

?

Page 68: ARTIFICIAL INTELLIGENCE - WordPress.com · Artificial Intelligence History Networks and Communication Department • Although artificial intelligence as an independent field of study

References

Networks and Communication Department

¨  Behrouz Forouzan and Firouz Mosharraf, “Foundations of computer science”, Second edition, chapter18, pp. 466-490