36
Rule Based Expert Systems Hasan Zafari ه دوم س ل ج

Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

Embed Size (px)

Citation preview

Page 1: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

Rule Based Expert Systems

Hasan Zafari

دوم جلسه

Page 2: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

outline

قواعد بر مبتنی های سیستم قواعد بر مبتنی خبره سیستم اجزای قواعد بر مبتنی های سیستم در استنتاج انواع سیستمPost مارکف الگوریتم رته الگوریتم

Page 3: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

what is knowledge?

Knowledge is a theoretical or practical understanding of a subject or a domain. Knowledge is also the sum of what is currently known, and apparently knowledge is power. Those who possess knowledge are called experts.

Anyone can be considered a domain expert if he or she has deep knowledge (of both facts and rules) and strong practical experience in a particular domain. The area of the domain may be limited. In general, an expert is a skillful person who can do things other people cannot.

Page 4: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

به را دانش آنکه بجای قواعد، بر مبتنی های سیستم درقواعد از ای مجموعه از دهیم، نمایش ایستا و اعالنی صورتیدهد می را امکان این ما به که کنیم می استفاده کار این برایای نتیجه یا شود انجام بایستی شرایط هر که عملی بتوانیم تا

دهیم تشخیص را است دستیابی قابل شرایط هر در که قواعد از ای مجموعه از قواعد بر مبتنی سیستم -IFیک

THEN از ای که factمجموعه دستورات مفسر یک و هاکند می مشخص حقایق به توجه با را قواعد گیری بکار ترتیب

است شده تشکیل

Page 5: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

Rules as a knowledge representation technique

The term rule in AI, which is the most commonly used type of knowledge representation, can be defined as an IF-THEN structure that relates given information or facts in the IF part to some action in the THEN part. A rule provides some description of how to solve a problem. Rules are relatively easy to create and understand.

Any rule consists of two parts: the IF part, called the antecedent (premise or condition) and the THEN part called the consequent (conclusion or action).

Page 6: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

قواعد بر مبتنی سیستم

The human mental process is internal, and it is too complex to be represented as an algorithm. However, most experts are capable of expressing their knowledge in the form of rules for problem solving.

از استفاده دانش بیان برای های روش ترین ساده از یکیاست قواعد

دستور یک صورت به توان می را قاعده IF-Thenهرنوشت

گویند هم تولید قواعد اینچنینی قواعد به

Page 7: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

23/4/19 EIE426-AICV 7

Example 1: ZOOKEEPER – A Deduction SystemTo identify seven animals, a cheetah, a tiger, a giraffe, a zebra, an

ostrich, a penguin, and an albatross.

مثال: استفاده از قواعد برای شناسایی هفت حیوان باغ وحش

cheetah

ostrich

penguin

zebra

albatross

giraffe

tiger

A deduction system: The then patterns specify new assertions (xx is or are yy).

Page 8: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

23/4/19 EIE426-AICV 8

Rules in ZOOKEEPERZ1 If ?x has hair

then ?x is a mammal

Z2 If ?x gives milkthen ?x is a mammal

Z3 If ?x has feathersthen ?x is a bird

Z4 If ?x flies?x lays eggs

then ?x is a bird

Z5 If ?x is a mammal?x eats meat

then ?x is a carnivore

Page 9: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

23/4/19 EIE426-AICV 9

Z6 If ?x is a mammal?x has pointed teeth?x has claws?z has forward-pointing eyes

then ?x is a carnivore

Z7 If ?x is a mammal?x has hoofs

then ?x is an ungulate

Z8 If ?x is a mammal?x chews cud

then ?x is an ungulate

Z9 If ?x is a carnivore?x has tawny color?x has dark spots

then ?x is a cheetah

Page 10: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

23/4/19 EIE426-AICV 10

Z10 If ?x is a carnivore?x has tawny color?x has black strips

then ?x is a tiger

Z11 If ?x is an ungulate ?x has long legs ?x has long neck ?x has tawny color?x has dark spots

then ?x is a giraffe

Z12 If ?x is an ungulate?x has white color?x has black stripes

then ?x is a zebra

Page 11: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

23/4/19 EIE426-AICV 11

Z13 If ?x is a bird?x does not fly?x has long legs?x has long neck?x is black and white

then ?x is an ostrich

Z14 If ?x is a bird?x does not fly?x swims?x is black and white

then ?x is a penguin

Z15 If ?x is a bird?x is a good flyer

then ?x is an albatross

Page 12: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

بر مبتنی خبره سیستم اجزایقواعد

Page 13: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

User

ExternalDatabase External Program

Inference Engine

Knowledge Base

Rule: IF-THEN

Database

Fact

Explanation Facilities

User Interface DeveloperInterface

Expert System

Expert

Knowledge Engineer

Page 14: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

بر مبتنی خبره سیستم اجزایقواعد

کاربر با ارتباط بخش . ساده و متنی است ممکن خبره سیستم و کاربر بین ارتباط برقراری برای مکانیزمی

پیچیده و گرافیکی یا و باشد

حل راه توضیح امکانات . در رفته بکار قواعد نمایش با مثال دهد می نمایش کاربر به را سیستم استدالل نحوه

استنتاج

کاری حافظهجریان در و است شده اثبات آنها درستی که است حقایقی شامل که موقت حافظه

. هستند تغییر حال در مرتبا حافظه این در موجود حقایق شوند می استفاده استنتاج

دانش پایگاه . در موجود قواعد شود می شامل را خبره سیستم نیاز مورد قواعد که مدت بلند حافظهتولیدی حافظه آن به و کنند می تعیین را شرایط هر در ممکن اقدامات مجموعه سیستم

گویند هم

Page 15: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

ادامه..

استنتاج موتورو اند شده فعال و ارضا واقعیات توسط قواعد کدام کند می تعییناجرا بعد مرحله در بایستی کدام شده فعال قواعد بین از همچنین

شود

( عملیات (Agendaبرنامهموتور توسط که شده فعال قواعد از شده بندی اولویت لیستی

است شده تهیه استنتاج

دانش کسب تسهیالتتکمیل ) برای سیستم به دانش کردن اضافه برای خودکار روشی

) است شده وارد دانش مهندس توسط قبال که دانشی

Page 16: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

Production system model

Conclusion

REASONING

Long-term Memory

ProductionRule

Short-term Memory

Fact

Page 17: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

Basic structure of a rule-based expert system

Page 18: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

The knowledge base contains the domain knowledge useful for problem solving. In a rule- based expert system, the knowledge is represented as a set of rules. Each rule specifies a relation, recommendation, directive, strategy or heuristic and has the IF (condition) THEN (action) structure. When the condition part of a rule is satisfied, the rule is said to fire and the action part is executed.

The database includes a set of facts used to match against the IF (condition) parts of rules stored in the knowledge base.

Page 19: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

قواعد از مثل

IF the ‘traffic light’ is green

THEN the action is go

IF the ‘traffic light’ is redTHEN the action is stop

Page 20: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

بر مبتنی های سیستم در استنتاج انواعقواعد

) گرا ) داده پیشرو استنتاج می ناشی واقعیات آن از که برسد نتایجی به تا کند می استدالل به شروع واقعیات از

شوند است تر مناسب کنترل و نظارت بینی، پیش مسائل در

) گرا ) هدف پسرو استنتاج برعکس استنتاج با کند می سعی و کند می شروع شود اثبات بایستی که ای فرضیه از

کند می پشتیبانی آنرا که برسد واقعیاتی به >- >- سوال: -< باران بارش فرضیه شود می وارد که شخصی خیس لباس مشاهده مثال

فرضیه اثبات است تر مناسب تشخیص مسائل در

Page 21: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

Forward chaining

Match Fire Match Fire Match Fire Match Fire

Knowledge Base

Database

A C E

X

Database

A C E

L

Database

A D

YL

B

X

Database

A D

ZY

B

LX

Cycle 1 Cycle 2 Cycle 3

X & B & E

ZY & D

LC

L & M

A X

N

X & B & E

ZY & D

LC

L & M

A X

N

X & B & E

ZY & D

LC

L & M

A X

N

X & B & E

ZY & D

LC

L & M

A X

N

Knowledge Base Knowledge Base Knowledge Base

X

C E C EB D B D

Y Y Y Y

Page 22: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

جدید حیوانی شناسایی

نام با جدیدی حیوان کنیم که Stretchفرض است شده داده: است زیر مشخصات دارای

Stretch has hair. Stretch chews cud. Stretch has long legs. Stretch has a long neck. Stretch has tawny color. Stretch has dark spots

فوق های ویژگی کمک استفاده و پیشرو زنجیره روش با داریم قصدکنیم شناسایی را حیوان این

Page 23: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

با حیوانی شناسایی برای پیشرو زنجیره Stretchنام

Page 24: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

زنجیره با جدیدی حیوان شناساییپسرو

نام با جدیدی شده Swiftyحیوان داده زیر مشخصات باکنید. شناسایی آنرا پسرو زنجیره کمک با است

–Swifty has tawny color–Swifty has dark spots–Swifty has hair–Swifty has forward pointing eyes–Swifty has claws–Swifty has teeth

Page 25: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

با حیوانی شناسایی برای پسرو زنجیره Swiftyنام

Page 26: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

پیشرو استنتاج های ویژگی

Forward chaining is a technique for gathering information and then inferring from it whatever can be inferred.

However, in forward chaining, many rules may be executed that have nothing to do with the established goal.

Therefore, if our goal is to infer only one particular fact, the forward chaining inference technique would not be efficient

Page 27: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

23/4/19 EIE426-AICV 27

Backward chaining

Page 28: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

How do we choose between forward and backward chaining?

If an expert first needs to gather some information and then tries to infer from it whatever can be inferred, choose the forward chaining inference engine.

However, if your expert begins with a hypothetical solution and then attempts to find facts to prove it, choose the backward chaining inference engine

Page 29: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

استنتاج چرخه

دوره هر به که کند می عمل ای دوره صورت به استنتاج سیکل موتوراجرا- عملیات انتخاب نشده برقرار پایان شرط که زمانی تا آن در که گویند

: دهد می انجام را زیرتناقض : 1. رفع اجرا برای بعدی دستور انتخاب

بایستی – دارد وجود اجرا برای شده فعال قانون یک از بیش اجرا چرخ یک در که زمانیآن به که شود اجرا بایستی قانون کدام کند مشخص که باشد داشته وجود مکانیزمی

conflict resolution گویند

اجرا2.– ) های ) قسمت شده Thenانجام انتخاب قانوناز – شده اجرا قانون agendaحذف

agendaبروزرسانی: تطبیق3.به – قوانینی کردن است agendaاضافه شده براورده آنرا مقدم که

Page 30: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

تولید های Postسیستم

از رشته یک قواعد از ای مجموعه کمک با که هایی سیستم بهتولید های سیستم کنند می تبدیل دیگر رشته به را Postنمادها

از. درکی هیچ بدون که آنست ها سیستم این ویژگی گویندکند می تبدیل یکدیگر به را آنها تنها ها سمبل معانی

اصلی هدایت محدودیت برای کنترل استراتژی فقدان آنهاقواعد بکارگیری

مثالدارد – تب دهید بیمار آسپرین او بهشود – نمی روش کنید ماشین بررسی را باطریشود – نمی روش کنید ماشین بررسی را بنزین مخزن

Page 31: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

مارکف الگوریتم

یک از که تولید های سیستم برای کنترلی ساختار تعریفقواعد ترتیب اعمال تعیین برای شده مرتب مجموعه

کند می استفاده بعدی قاعده نباشد اجرا قابل اولویت باالترین با قاعده اگر

بعدی قواعد برای ترتیب همین به و شد خواهد اجرا لیستمحدودیت

است پایین کارایی و سرعت دارای قاعده هزاران یا صدها با هایی سیستم برای

پایان شرطنباشد – اجرا قابل هم لیست قاعده آخرین

Page 32: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

مارکف الگوریتم از مثال

Page 33: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

رته الگوریتم

سیستم برای که بود این مارکف الگوریتم مشکلنبود مناسب قاعده زیادی تعداد با هایی

روشی از اولویت لیست به نیاز بدون رته الگوریتمبایستی که بعدی قاعده شناسایی برای هوشمندانه

کند می استفاده شود اجرا که کند می استفاده ای شبکه از رته الگوریتم

اجرای تاثیر نحوه و قاعده هر به مربوط اطالعاتبرد می بهره ها قاعده دیگر روی قاعده هر

Page 34: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

قاعده بر مبتنی سیستم مزایای

Natural knowledge representation. An expert usually explains the problem-solving procedure with such expressions as this: “In such-and-such situation, I do so-and-so”. These expressions can be represented quite naturally as IF-THEN production rules.

Uniform structure. Production rules have the uniform IF-THEN structure. Each rule is an independent piece of knowledge. The very syntax of production rules enables them to be self-documented.

Separation of knowledge from its processing. . The structure of a rule-based expert system provides an effective separation of the knowledge base from the inference engine. This makes it possible to develop different applications using the same expert system shell.

Dealing with incomplete and uncertain knowledge. . Most rule-based expert systems are capable of representing and reasoning with incomplete and uncertain knowledge.

Page 35: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج

قواعد بر مبتنی های سیستم معایب

Opaque relations between rules. Although the individual production rules are relatively simple and self-documented, their logical interactions within the large set of rules may be opaque. Rule-based systems make it difficult to observe how individual rules serve the overall strategy.

Ineffective search strategy. The inference engine applies an exhaustive search through all the production rules during each cycle. Expert systems with a large set of rules (over 100 rules) can be slow, and thus large rule-based systems can be unsuitable for real-time applications.

Inability to learn. In general, rule-based expert systems do not have an ability to learn from the experience. Unlike a human expert, who knows when to “break the rules”, an expert system cannot automatically modify its knowledge base, or adjust existing rules or add new ones. The knowledge engineer is still responsible for revising and maintaining the system.

Page 36: Rule Based Expert Systems Hasan Zafari جلسه دوم. outline سیستم های مبتنی بر قواعد اجزای سیستم خبره مبتنی بر قواعد انواع استنتاج