chap ii: knowledge representation

31
Chap II: Knowledge Chap II: Knowledge Representation Representation 1 . ب س حا لم ا ا ظ ل ن خ دا ة رف مع لء ا ا ن ب ي ن ع ت ة رف مع ل ل ا ن# ث م ت ي ن ل ع ا ي ض وا م ل ’م ا ه/ ا# ’ب ح ب ل ا ات3 ي ح ب ب را ت س وا ة ف ر مع ل ل ا ن# ث م ت ر ت ت ع ت. ي ع ا ن صطلاء ا كا و الذ س دار ها ب م ت ه ا

Upload: landis

Post on 02-Feb-2016

118 views

Category:

Documents


0 download

DESCRIPTION

Chap II: Knowledge Representation. تمثيل المعرفة تعني بناء المعرفة داخل نظام الحاسب. يعتبر تمثيل المعرفة واستراتيجيات البحث أهم المواضيع التي اهتم بها دارسو الذكاء الاصطناعي. Knowledge Representation. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chap II: Knowledge Representation

Chap II: Knowledge Chap II: Knowledge RepresentationRepresentation

1

تمثي�ل المعرف�ة تع�ني بن�اء المعرف�ة داخ�لنظام الحاسب.

يعت��بر تمثي��ل المعرف��ة واس��تراتيجياتالبحث أهم المواض�يع ال�تي اهتم به�ا دارس�و

الذكاء االصطناعي.

Page 2: Chap II: Knowledge Representation

Knowledge Knowledge RepresentationRepresentation

المقص�ود بتمثي�ل المعرف�ة ه�و جع�ل الحاس�ب يعم�ل م�اي�ري���ده �العق���ل� ا�لبش���ري� �بحيث �يفك���ر ك�م���ا ي�ف�ك���ر

اإلنس�ان ، �فيأخ�ذ الم�علوم�ات و �يحلله�ا مث�ل� اإلنسان.. يدوي��ة ب��ل Tوالنظم الم��راد تطويره��ا ليس��ت نظم��ا

حاس�وبي�ه ذات �ذك�اء متط�ور.� و م�ن هن�ا ظه�رت الحاج�ة إلى ا�لمعرفة .. و �لكن كيف تمثل �هذه ا�لمع�رفة؟!

في الواق�ع ف�إن المناقش�ة العادي�ة ال�تي أتع�رف فيه�اع�لى� ش�خص م�ا� ، ف�إنن�ي �آخ�ذ م�جم�وع�ة من �الم�علوم�ات �عن �ه�ذا �ا�لش�خص �م�ث�ل: ا�س�مه�،رق�م�ه،ص�ورته،عن�وان�ه..

و �هذه كل�ها �معلومات� اختزنها ف�ي عقلي�. و لكن في حال�ة الحاس�ب اآللي فإنن�ا نري�ده أن يفك�ر

بلغ��ة �الو�اق��ع و� ا�لعق��ل و �ل�يس ب��أي لغ��ة من� �اللغ��ات المعروفة للحاسب..

Page 3: Chap II: Knowledge Representation

Data, Information, Data, Information, KnowledgeKnowledge? ?

3

DATA

INFORMATION

KNOWLEDGE

WISDOM

Non-algorithmic(heuristic)

Algorithmic

Non-programmable

programmable

حكمة

Page 4: Chap II: Knowledge Representation

Physical Symbol System Physical Symbol System Hypothesis (P2SH)Hypothesis (P2SH)

نشاط الذكاء في كل من اإلنسان واآللة يتم تحصيله عبر:-

أنماط رمزية : لتمثيل خصائص المشكلة المختارة.

عمليات : لتوليد حلول ممكنة.

بحث: الختيار أفضل حل أو حلول.

4

Page 5: Chap II: Knowledge Representation

The Example of Representation The Example of Representation (())

3.142

5

The example to present pi value.

The decimal equivalent

The real number

Floating point 3142 1

exponent

mantissa

11100010 Computer

memory

{Abstraction}

High (human)

Low (machine)

Page 6: Chap II: Knowledge Representation

Knowledge Knowledge Representation Representation TechniquesTechniques

6

TECHNIQUES

Object-Attribute Value

Framesاالطارات

Semantic Networks

الشبكات الداللية

Logicالمنطق

Rulesالقواعد

Page 7: Chap II: Knowledge Representation

Object-Attribute-Value Object-Attribute-Value (OAV)(OAV)

7

Using fact : “صياغة المعرفة التعريفية”

اإلشارة لقيمة خصائص معينة لشيء ما•

•Eg: The ball’s color is red (assign red to the ball’s color) مثال لون الكرة أحمر ) تحديد األحمر كلون للكرة(

•The object can be physical (eg: car, books) or abstract (eg: love, hobby) الكائن يمكن أن يكون شيئا ماديا أو معنويا.

•The value can be numerical, string or Boolean! القيمة.يمكن أن تكون عددية ، تسلسلية أو منطقية

•It could be either single or multi valued from different attributes and objects. يمكن أن تكون مفردة أو متعددة القيممن سمات أو أشياء أخرى

Used in MYCIN

Page 8: Chap II: Knowledge Representation

OAV Triplets Diagram OAV Triplets Diagram (i)(i)

8

Fact :=: “The chair’s color is red and priced at $ 35.00 ”

CHAIR

RED

$ 35.00

Color

Priced

Object Attribute Value

Page 9: Chap II: Knowledge Representation

OAV Triplets Diagram OAV Triplets Diagram (ii)(ii)

9

Fact :=: “TIN 313 is a compulsory subject for MSc Int Sys., code for Artificial Intelligence, and taught by Mr Yousef Salahat”

TIN 313

MSc Int. Sys

Mr Yousef Salahat

Compulsory subject

Taught

Artificial Intelligence

Code

Page 10: Chap II: Knowledge Representation

Rules BasedRules Based

10

القواعد : هيكل المعرفة التي تربط بعض المعلومات بمعلومات أخرى والتي يمكن استنتاجها أو االستدالل بها

.لمعرفتها

IF condition THEN action statements.      )premise              )goal      antecedent(          consequent(

•Example IF “Temperature is hot” THEN “turn on the air-conditioning system”

مثال. لو ) الحرارة عالية( فإنه يتوجب ) تشغيل نظام .التبريد(

Page 11: Chap II: Knowledge Representation

Rules Based System (I)Rules Based System (I)

11

Rule 1:IF the ball’s color is red THEN I like the ball.

Rule 2:IF I like the ball THEN I will buy the ball.

IF ball’s color = red THEN like = ball

IF like = ball THEN will buy the ball

Ball’s color = red

Like = ball

Will buy = ball

Question: Ball’s color?

Answer: Red1

2

3

45

Working Memory

Knowledge Base

Page 12: Chap II: Knowledge Representation

Rules Based System (II)Rules Based System (II)

12

•Rule 1: IF x has a sore throat AND suspect bacterial infectionTHEN x has strep throat

•Rule 2:IF x temperature is > 37 cTHEN x has a fever

•Rule 3:IF x has been sick > a monthAND x has a feverTHEN suspect bacterial infection

•Patient’s temperature = 38 c

•Patient has been sick > 2 months

•Patient has a sore throat

•Conclusion ?

Patient has Strep throat

38حرارة المريض

المريض تعبان من شهرين

المريض لديه التهاب حلق

المريض لديه بكتيريا في الحلق

Page 13: Chap II: Knowledge Representation

Semantic NetworksSemantic Networks

13

هي إح�دى الط�رق المس�تخدمة في تمثي�ل المعرف�ة في النظم الخب����يرة .. وهي عب����ارة عن تمثي����ل

المعرفة على شكل تركيب شبكي ..

كل شبكة داللية:..nodes تدعى عقد Objectsمجموعة من •..nodes تربط بين Linkمجموعة من الروابط •

Exceptional handlingالمعالجة االستثنائية •

بعض االس�تثناءات لح�االت معين�ة ” ك�ل الطي�ور ق�ادرة على الط�يران والنعام�ة ط�ير“ ه�ل يمكن للنعام�ة أن

تطير؟

Page 14: Chap II: Knowledge Representation

The Example of Semantic The Example of Semantic Networks (Bird)Networks (Bird)

14

FACT : Parrot is a bird. Typically bird has wings and travel by flying. Bird category falls under animal kingdom. All animal requires air to breathe. Ostrich is a bird but travels by walk.

Animalحيوان

Animalحيوان

BirdطائرBirdطائر

Wingsأجنحة

Wingsأجنحة

Parrotالببغاء

Parrotالببغاء

AirالهواءAir

الهواء

Ostrichالنعامة

Ostrichالنعامة

WalkمشيWalkمشي

FlyيطيرFly

يطير

is-a

travel

travel

has

is-a

Breathe يتنفس

“exceptional handling”

Page 15: Chap II: Knowledge Representation

FramesFrames

15

و هي إح�دى الط�رق المس�تخدمة لتمثي�ل المعرف�ة في النظم الخب��يرة و هي طريق��ة خاص��ة لكتاب��ة بيان��ات المعرف��ة على ش��كل هيك��ل ع��ام يحت��وي

إطارات.

•Extension : schemas and basic to OOP

•Class frame خصائص عامة لبعض األشياء العامةمثال. إطار التصنيف طائر يشير إلى خصائص عامة

.للطائر

•Instance frame لوصف خصائص فريدة من إطارالتصنيف مثال. الصنف نعامة من إطار الصنف

طائر

Page 16: Chap II: Knowledge Representation

Frames StructureFrames Structure

16

Frame Name: BIRD

Properties:

Color = unknown

Wings = 2

Flies = True

Frame Name: OSTRICH

Properties:

Color = brown/dark

Wings = 2

Flies = False

Class Name: BIRD

Page 17: Chap II: Knowledge Representation

LogicLogic المنطق الرياضي المنطق الرياضي

17

•The oldest representation existed أقدم تمثيل موجود.

•Implemented using PROLOG, LISP programming language.

تمثي~ل المعرف~ة وبن~اء قواع~دها يتطلب تحوي~ل ه~ذه الجم~ل إلى •صيغ يسهل تمثيلها داخل أنظمة الحاسب.

أم~ا أن Propositional Logicوالجم~ل وف~ق المنط~ق االفتراض~ي •تكون جمل بسيطة أو جمل مركبة.

Page 18: Chap II: Knowledge Representation

Logical OperatorsLogical Operators

General Name

Formal Name

Symbols

Not Negation

And Conjunction

Or Disjunction

If… Then/Implies

Conditional

If and only if Biconditional

وإذ أخ~~~ذنا المع~~~اني ال~~~تي نستخلص~~~ها من ه~~~ذه الجم~~~ل نج~دها أم~ا أن تق~دم إخ~ب~ارا )~ حق~ائق( أو قواع~~~~د، وه~~~~ذه الحق~~~~~~~~~~~ائق أ~و ال~قو~اع~~~د أ~م~~~ا أن ت~ك~~ون ص~~حيحة~ أو~

True orخا~طئ~~ة ~)False.)

18

Page 19: Chap II: Knowledge Representation

FactsFacts الحقائق الحقائق

19

وهي الجم~ل ال~تي تص~ف ش~يئا م~ا أو تخ~بر عن ش~يء م~ا س~واء ك~انت ه~ذه الجمل~ة جمل~ة اس~مية أو فعلي~ة أو ش~به جمل~ة، على

سبيل المثال:

Artificial intelligence is a computerالذكاء االصطناعي مقرر حاسب •system

Cat is an animalالقط حيوان •

وقد تكون الحقيقة مركبة

Ahmed mother is married toأم احمد متزوجة من والد خالد •Khalid father

(Trueوهذه الحقائق كلها حقائق صحيحة )

Cat is humanأما إذا أخذنا الجملة التالية : •

( falseفهي حقيقة خاطئة )

Page 20: Chap II: Knowledge Representation

RulesRules القواعدالقواعد

20

وهي الجم��ل ال��تي يمكن تعميمه��ا أو تطبيقه��ا على مجموع�ة من األش�ياء ويل�زم تطبيقه�ا ت�وفر ش�رط أو

مجموعة شروط.

Easy come easy goما يكسب بسهولة يضيع بسهولة •

every way has an answerلكل سؤال جواب •

على سبيل ifقد تكون القاعدة في صورة جملة المثال:

ifإذا كان الحيوان يعطي حليبا أذا الحيوان من ذوات الثدييات •animal give milk it is a mammal

Page 21: Chap II: Knowledge Representation

Predicate Calculus Logic Predicate Calculus Logic (FOPL)(FOPL)

21

والشكل العام لتركيب الجمل وفق المنطق الرياضي •هو:

operator (variables_1, variables_2,…)

EXAMPLES:

COMPUTER_COURSE(ARTIFICIAL_INTELLEGIENCE)

ANIMAL(CAT)

Page 22: Chap II: Knowledge Representation

جدول: الرموز المستخدمة في التمثيل جدول: الرموز المستخدمة في التمثيل الرياضي للمنطقالرياضي للمنطق

Meaningالمعنى Symbolالرمز

For Allلكل

Exist يوجد

NOT نفي

Andو

OR أو v

Then أذا

Greater thanأكبر من gt

Less than أقل من lt

Greater than orأكبر من أو يساوي equal

ge

Less than or equalأقل من أو يساوي le

equal يساوي =22

Page 23: Chap II: Knowledge Representation

Predicate Calculus Logic Predicate Calculus Logic (FOPL)(FOPL)

23

•Example: “She likes chocolate” likes (she, chocolate).

•Universal quantifier (X) to show all object is true [Eg: All students (X (student (X))]

• Existential quantifier (X) to show existence / partial object is true [ Eg: Some people ( X (people (X))]

Page 24: Chap II: Knowledge Representation

The Example of FOPLThe Example of FOPL

24

Normal: “If it doesn’t rain today, Ahmad will go to the beach. FOPL: rain( today) go(Ahmad, beach)

Normal: “All volleyball players are tall” FOPL: X (volleyball_player (X) tall (X))

Normal: Some people like durian. FOPL: X (person(X) likes(X, durian))

Normal: Nobody likes wars FOPL: X likes (X, wars)

Page 25: Chap II: Knowledge Representation

The Truth TableThe Truth Table

P Q NOT

(P)

AND

P ^ Q

OR

P v Q

Implies

P Q

Biconditional

P Q

T T F T T T T

T F F F T F F

F T T F T T F

F F T F F T T

25

Page 26: Chap II: Knowledge Representation

The Example of Logical The Example of Logical OperationOperation

P Q P Q P ^ (P Q) (P ^ (P Q)) Q

T T T T T

T F F F T

F T T F T

F F T F T

26

Consider P and Q as a propositional statement. Show the result when (P ^ (P Q)) Q

Page 27: Chap II: Knowledge Representation

Implementing Implementing Propositional LogicPropositional Logic

P Q P Q

T T T

T F F

F T T

F F T

27

“IF the battery is dead THEN the car won’t start”

•P = battery is dead & Q = car won’t start

•Battery is dead = T, car won’t start = T

•“Battery not dead” = F, “car will start” = F

•Equivalence to P Q

Page 28: Chap II: Knowledge Representation

The Example of PROLOG The Example of PROLOG LanguageLanguage

28

son(ahmad,abdullah).son(abdullah,abdul_karim).

grandfather(X,Y):-fahter(X, Somebody),fahter(Somebody, Y).

father(X,Y):-son(Y,X).

son(ahmad,abdullah).son(abdullah,abdul_karim).

grandfather(X,Y):-fahter(X, Somebody),fahter(Somebody, Y).

father(X,Y):-son(Y,X).

Code

?- grandfather(X,Y).X = abdul_karim ,Y = ahmad ;

?- father(X,Y).X = abdullah ,Y = ahmad ;

X = abdul_karim ,Y = abdullah

?- grandfather(X,Y).X = abdul_karim ,Y = ahmad ;

?- father(X,Y).X = abdullah ,Y = ahmad ;

X = abdul_karim ,Y = abdullah

Output

My name is Ahmad bin Abdullah. My father is Abdullah bin Abdul Karim.

Page 29: Chap II: Knowledge Representation

The Application from The Application from PROLOG LanguagePROLOG Language

29

Games: Reversi

Travelling Salesman Analysis

Congkak!

Page 30: Chap II: Knowledge Representation

30

Mammals Mammals

PersonPerson

Female Person

Female Person

Male

Person Male

Person

Mariam Mariam Ahmad Ahmad

HasMother

Sister of

Subset of

Member of

Subset-of

Subset-of

Member of

2legs

legs

1

الشكل التالي يعبر عن شبكة داللية لعالقة أسرية. يمكننا

من خالل هذا الشكل أن نعبر عن هذه العالقات قي

صورتين:.جمل وفق المنطق 1

الرياضي. أطر جدوليه2

Page 31: Chap II: Knowledge Representation

Sister_of)Mariam,Ahmed(Legs)Ahmed(=1Member_of)Mariam,Female_Person(

Ahmed اإلطار الخاص ب : Ahmed

Member of : Male PersonLegs: 1

Has Sister : Mariam

Person اإلطار الخاص بPerson:

Subset of : MammalLegs: 2

Has Mother : Female Person

31

الشكل التالي يعبر عن شبكة داللية لعالقة أسرية. يمكننا من خالل هذا الشكل أن نعبر عن هذه العالقات قي صورتين:

.جمل وفق المنطق الرياضي1 . أطر جدولية2

:حالة استثنائيةأحمد له رجال

واحدة بينما لكل البشر رجالن