Rule Based Systems

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 53

Rule based systems

FRANK VENANCE Department mathematics computational science & Engineering

Rule based systems / Knowledge based systems/ Expert Systems A rule means a structure which has an if component and a then component.

rule based systems are:

Systems that utilize reasoning capabilities and draw conclusions. Computer programs that contain some subject-specific knowledge of one or more human rule based Made up of a set of rules that analyze user supplied information about a specific class of problems.

Terms Associated with rule based Systems


Knowledge Engineering building an rule based system Knowledge Engineers the people who build the system Knowledge Representation the symbols used to represent the knowledge Factual Knowledge knowledge of a particular task domain that is widely shared

Example The Edwin Smith papyrus Title: Instructions for treating a fracture of the cheekbone. Symptoms: If you examine a man with a fracture of the cheekbone, you will find a salient and red fluxion, bordering the wound.

Diagnosis and prognosis:


Then you will tell your patient: "A fracture of the cheekbone. It is an injury that I will cure.

Treatment:

You shall tend him with fresh meat the first day. The treatment shall last until the fluxion resorbs. Next you shall treat him with raspberry, honey, and bandages to be renewed each day, until he is cured.

Rule-based reasoning: rules


examples: if - the leaves are dry, brittle and discoloured then - the plant has been attacked by red spider mite if - the customer closes the account then - delete the customer from the database

Rule-based reasoning: rules

The statement, or set of statements, after the word if represents some pattern which you may observe. The statement, or set of statements, after the word then represents some conclusion that you can draw, or some action that you should take.

A rule-based system, therefore, either identifies a pattern and draws conclusions about what it means, or identifies a pattern and advises what should be done about it, or identifies a pattern and takes appropriate action.

Problem-solving Models
Forward-chaining starts from a set of conditions and moves towards some conclusion Backward-chaining starts with a list of goals and the works backwards to see if there is any data that will allow it to conclude any of these goals. Both problem-solving methods are built into inference engines or inference procedures

Forward and Backward Chaining


Rules
r1: IF may rain THEN should take umbrella r2: IF cloudy THEN may rain

Questions
Should I take an umbrella? What should I do if it is cloudy?

Backward Chaining
Rules
R1: IF may rain THEN should take umbrella R2: IF cloudy THEN may rain

Should I take an umbrella?


Do the rules indicate I should take an umbrella?
Is there a rule about taking umbrellas?
R1: goal: should take umbrella

How can I prove that goal?


What has to be true for r1 to hold? may rain is the antecedent of r1

Can I prove that it may rain?


R2: goal: may rain

How can I prove that goal2


What has to be true for r2 to hold cloudy is the antecedent of r2

How can I prove cloudy?

Backward Chaining

Goal_2 Goal_3
rules

Goal_3 Goal_4 Goal_4 Goal_5

Question

Direction of reasoning

Goal_1 Goal_2

Architecture of a typical expert system


User interface:
Knowledge base

Question-andanswer
Menu driven

Knowledgebase editor General knowledgebase

User
Natural language

Inference engine

Case-specific
data

Graphic
inteface
Expert system shell

Explanation subsystem

When to Use Rule-Based Systems


Problem domain: one of the usage problems with rule based systems is that you have to know the solution to the problem beforehand. The problem has to be solvable by reasoning along axioms or principles.
The problem space needs to be quantifiable in terms of facts and the domain knowledge must be quantifiable in terms of rules.

The output is in the form of a terse or verbose recommendation, the explanation of which is typically a trace of all the rules that fired.

Uses of rule based Systems

Very useful to companies with a high-level of experience and rule basedise that cannot easily be transferred to other members. Solves problems that would normally be tackled by a medical or other professional. Currently used in fields such as accounting, medicine, process control, financial service, production, and human resources

Tree searching technique

FRANK VENANCE Department mathematics computational science & Engineering

Search Techniques
The process of the solution of AI problem searches the path from start sate to goal state Search techniques help in finding the most viable path to reach the goal state

Search techniques make the entire search process efficient and economical

Types of trees:

Spanning tree Rooted tree Binary tree

Tree searching technique

Searching techniques

Depth First Search Breath First Search

Breadth First Search - Method


Expand Root Node First Expand all nodes at level 1 before expanding level 2
OR

Expand all nodes at level d before expanding nodes at level d+1

Breadth-first Search
A Successors: B,C,D B G C
Initial state

N O

Goal state

Visited:

Fringe: A (FIFO)

The fringe is the data structure we use to store all of the nodes that have been generated

Breadth-first Search
A
Next node

Successors: E,F E

B G

C H I

N O

Visited: A

Fringe: B,C,D (FIFO)

Breadth-first Search
A
Next node

Successors: G,H

B G

C H I

N O

Visited: A, B

Fringe: C,D,E,F (FIFO)

Breadth-first search
A

Successors: I,J
B G C H I

Next node

N O

U Visited: A, B, C

Fringe: D,E,F,G,H (FIFO)

Breadth-first Search
A Successors: K,L B
Next node

C G H I

N O

Visited: A, B, C, D

Fringe: E,F,G,H,I,J (FIFO)

Breadth-first Search
A

Successors: M
B
Next node

C G H I

N O

Visited: A, B, C, D, E

Fringe: F,G,H,I,J,K,L (FIFO)

Breadth-first Search
A

Successors: N
B
Next node

C G H I

N O

Visited: A, B, C, D, E, F

Fringe: G,H,I,J,K,L,M (FIFO)

Breadth-first Search
A

Successors: O
B G C
Next node

N O

Visited: A, B, C, D, E, F, G

Fringe: H,I,J,K,L,M,N (FIFO)

Breadth-first Search
A Successors: P,Q B G C H I

D
Next node

N O

U Visited: A, B, C, D, E, F, G, H

Fringe: I,J,K,L,M,N,O (FIFO)

Breadth-first Search
A Successors: R B G C H I

D
Next node

N O

Visited: A, B, C, D, E, F, U G, H, I

Fringe: J,K,L,M,N,O,P,Q (FIFO)

Breadth-first Search
A Successors: S B G C H I

E
Next node

N O

U Visited: A, B, C, D, E, F, G, H, I, J

Fringe: K,L,M,N,O,P,Q,R (FIFO)

Breadth-first Search
A

Successors: T
B G C H I

E
Next node

N O

U Visited: A, B, C, D, E, F, G, H, I, J, K

Fringe: L,M,N,O,P,Q,R,S (FIFO)

Breadth-first Search
A

Successors:

B G

C H I

M
Next node

N O

U Visited: A, B, C, D, E, F, G, H, I, J, K, L

Fringe: M,N,O,P,Q,R,S,T (FIFO)

Breadth-first Search
A Goal state achieved

Successors:

B G

C H I

N O
Next node

Visited: A, B, C, D, E, F, U G, H, I, J, K, L, M

Fringe: N,O,P,Q,R,S,T (FIFO)

Depth First Search - Method


Expand Root Node First Explore one branch of the tree before exploring another branch If a leaf node do not represent a goal state, search backtracks up to the next highest node that has an unexplored path

Depth First Search

Depth-first search (DFS) is an algorithm for traversing or searching a tree, tree structure, or graph. One starts at the root (selecting some node as the root in the graph case) and explores as far as possible along each branch before backtracking.

Depth-First Search
A Successors: B,C,D B G C
Initial state

N O

Goal state

Visited:

Fringe: A (LIFO)

Depth-First Search
A Successors: E,F B G C H I

N O

Visited: A

Fringe: B,C,D (LIFO)

Depth-First Search
A Successors: K,L B G C H I

N O

Visited: A, B

Fringe: E,F,C,D (LIFO)

Depth-First Search
A

Successors: S
B G C H I

N O

Visited: A, B, E

Fringe: K,L,F,C,D (LIFO)

Depth-First Search
A

Successors:

B G

C H I

N O

Visited: A, B, E, K

Fringe: S,L,F,C,D (LIFO)

Depth-First Search
A

Successors: T
B G C H I

N O

Visited: A, B, E, K, S Backtracking

Fringe: L,F,C,D (LIFO)

Depth-First Search
A

Successors:

B G

C H I

N O

Visited: A, B, E, K, S, L S T U

Fringe: T,F,C,D (LIFO)

Depth-First Search
A Successors: M B G C H I

N O

Visited: A, B, E, K, S, L, T S T U Backtracking

Fringe: F,C,D (LIFO)

Depth-First Search
A

Successors:

B G

C H I

N O

Visited: A, B, E, K, S, L, T, U F

Fringe: M,C,D (LIFO)

Depth-First Search
A Successors: G,H B G C H I

N O

Visited: A, B, E, K, S, L, T, F, M Backtracking

Fringe: C,D (LIFO)

Depth-First Search
A

Successors: N

B G

C H I

N O

Visited: A, B, E, K, S, L, T, F, M, C

Fringe: G,H,D (LIFO)

Depth-First Search
A

Successors:

B G

C H I

Goal state achieved Finished search

N O

Visited: A, B, E, K, S, L, T, F, M, C, G

Fringe: N,H,D (LIFO)

Algorithm: Breadth-First Search


Algorithm: using a queue 1. Queue = [initial node] , FOUND = False 2. While queue not empty and FOUND = False do: Remove the first node N If N == target_node then FOUND = true Else find all successor nodes of N and put them into the queue.

Algorithm: Depth-first search


Algorithm: using a stack 1. Stack = [initial node] , FOUND = False 2. While stack not empty and FOUND = False do: Remove the top node N If N == target_node then FOUND = true Else find all successor nodes of N and put them onto the stack.

Comparison of depth-first and breadth-first search


Breadth-first: without backtracking Depth-first : backtracking.
Length of path: breadth-first finds the shortest path first. Memory: depth-first uses less memory

Time: If the solution is on a short path - breadth first is better, if the path is long - depth first is better.

Advantages of Depth-First Search

Depth-first search requires less memory since only the nodes on the current path are stored.

By chance, depth-first search may find a solution without examining much of the search space at all.

Advantages of Breadth-First Search

If there is a solution, then breadth-first search is guaranteed to find it

Breadth-first search will not get trapped exploring a blind alley

You might also like