chap ii: knowledge representation
DESCRIPTION
Chap II: Knowledge Representation. تمثيل المعرفة تعني بناء المعرفة داخل نظام الحاسب. يعتبر تمثيل المعرفة واستراتيجيات البحث أهم المواضيع التي اهتم بها دارسو الذكاء الاصطناعي. Knowledge Representation. - PowerPoint PPT PresentationTRANSCRIPT
Chap II: Knowledge Chap II: Knowledge RepresentationRepresentation
1
تمثي�ل المعرف�ة تع�ني بن�اء المعرف�ة داخ�لنظام الحاسب.
يعت��بر تمثي��ل المعرف��ة واس��تراتيجياتالبحث أهم المواض�يع ال�تي اهتم به�ا دارس�و
الذكاء االصطناعي.
Knowledge Knowledge RepresentationRepresentation
المقص�ود بتمثي�ل المعرف�ة ه�و جع�ل الحاس�ب يعم�ل م�اي�ري���ده �العق���ل� ا�لبش���ري� �بحيث �يفك���ر ك�م���ا ي�ف�ك���ر
اإلنس�ان ، �فيأخ�ذ الم�علوم�ات و �يحلله�ا مث�ل� اإلنسان.. يدوي��ة ب��ل Tوالنظم الم��راد تطويره��ا ليس��ت نظم��ا
حاس�وبي�ه ذات �ذك�اء متط�ور.� و م�ن هن�ا ظه�رت الحاج�ة إلى ا�لمعرفة .. و �لكن كيف تمثل �هذه ا�لمع�رفة؟!
في الواق�ع ف�إن المناقش�ة العادي�ة ال�تي أتع�رف فيه�اع�لى� ش�خص م�ا� ، ف�إنن�ي �آخ�ذ م�جم�وع�ة من �الم�علوم�ات �عن �ه�ذا �ا�لش�خص �م�ث�ل: ا�س�مه�،رق�م�ه،ص�ورته،عن�وان�ه..
و �هذه كل�ها �معلومات� اختزنها ف�ي عقلي�. و لكن في حال�ة الحاس�ب اآللي فإنن�ا نري�ده أن يفك�ر
بلغ��ة �الو�اق��ع و� ا�لعق��ل و �ل�يس ب��أي لغ��ة من� �اللغ��ات المعروفة للحاسب..
Data, Information, Data, Information, KnowledgeKnowledge? ?
3
DATA
INFORMATION
KNOWLEDGE
WISDOM
Non-algorithmic(heuristic)
Algorithmic
Non-programmable
programmable
حكمة
Physical Symbol System Physical Symbol System Hypothesis (P2SH)Hypothesis (P2SH)
نشاط الذكاء في كل من اإلنسان واآللة يتم تحصيله عبر:-
أنماط رمزية : لتمثيل خصائص المشكلة المختارة.
عمليات : لتوليد حلول ممكنة.
بحث: الختيار أفضل حل أو حلول.
4
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)
Knowledge Knowledge Representation Representation TechniquesTechniques
6
TECHNIQUES
Object-Attribute Value
Framesاالطارات
Semantic Networks
الشبكات الداللية
Logicالمنطق
Rulesالقواعد
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
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
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
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”
مثال. لو ) الحرارة عالية( فإنه يتوجب ) تشغيل نظام .التبريد(
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
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حرارة المريض
المريض تعبان من شهرين
المريض لديه التهاب حلق
المريض لديه بكتيريا في الحلق
Semantic NetworksSemantic Networks
13
هي إح�دى الط�رق المس�تخدمة في تمثي�ل المعرف�ة في النظم الخب����يرة .. وهي عب����ارة عن تمثي����ل
المعرفة على شكل تركيب شبكي ..
كل شبكة داللية:..nodes تدعى عقد Objectsمجموعة من •..nodes تربط بين Linkمجموعة من الروابط •
Exceptional handlingالمعالجة االستثنائية •
بعض االس�تثناءات لح�االت معين�ة ” ك�ل الطي�ور ق�ادرة على الط�يران والنعام�ة ط�ير“ ه�ل يمكن للنعام�ة أن
تطير؟
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”
FramesFrames
15
و هي إح�دى الط�رق المس�تخدمة لتمثي�ل المعرف�ة في النظم الخب��يرة و هي طريق��ة خاص��ة لكتاب��ة بيان��ات المعرف��ة على ش��كل هيك��ل ع��ام يحت��وي
إطارات.
•Extension : schemas and basic to OOP
•Class frame خصائص عامة لبعض األشياء العامةمثال. إطار التصنيف طائر يشير إلى خصائص عامة
.للطائر
•Instance frame لوصف خصائص فريدة من إطارالتصنيف مثال. الصنف نعامة من إطار الصنف
طائر
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
LogicLogic المنطق الرياضي المنطق الرياضي
17
•The oldest representation existed أقدم تمثيل موجود.
•Implemented using PROLOG, LISP programming language.
تمثي~ل المعرف~ة وبن~اء قواع~دها يتطلب تحوي~ل ه~ذه الجم~ل إلى •صيغ يسهل تمثيلها داخل أنظمة الحاسب.
أم~ا أن Propositional Logicوالجم~ل وف~ق المنط~ق االفتراض~ي •تكون جمل بسيطة أو جمل مركبة.
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
FactsFacts الحقائق الحقائق
19
وهي الجم~ل ال~تي تص~ف ش~يئا م~ا أو تخ~بر عن ش~يء م~ا س~واء ك~انت ه~ذه الجمل~ة جمل~ة اس~مية أو فعلي~ة أو ش~به جمل~ة، على
سبيل المثال:
Artificial intelligence is a computerالذكاء االصطناعي مقرر حاسب •system
Cat is an animalالقط حيوان •
وقد تكون الحقيقة مركبة
Ahmed mother is married toأم احمد متزوجة من والد خالد •Khalid father
(Trueوهذه الحقائق كلها حقائق صحيحة )
Cat is humanأما إذا أخذنا الجملة التالية : •
( falseفهي حقيقة خاطئة )
RulesRules القواعدالقواعد
20
وهي الجم��ل ال��تي يمكن تعميمه��ا أو تطبيقه��ا على مجموع�ة من األش�ياء ويل�زم تطبيقه�ا ت�وفر ش�رط أو
مجموعة شروط.
Easy come easy goما يكسب بسهولة يضيع بسهولة •
every way has an answerلكل سؤال جواب •
على سبيل ifقد تكون القاعدة في صورة جملة المثال:
ifإذا كان الحيوان يعطي حليبا أذا الحيوان من ذوات الثدييات •animal give milk it is a mammal
Predicate Calculus Logic Predicate Calculus Logic (FOPL)(FOPL)
21
والشكل العام لتركيب الجمل وفق المنطق الرياضي •هو:
operator (variables_1, variables_2,…)
EXAMPLES:
COMPUTER_COURSE(ARTIFICIAL_INTELLEGIENCE)
ANIMAL(CAT)
جدول: الرموز المستخدمة في التمثيل جدول: الرموز المستخدمة في التمثيل الرياضي للمنطقالرياضي للمنطق
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
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))]
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)
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
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
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
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.
The Application from The Application from PROLOG LanguagePROLOG Language
29
Games: Reversi
Travelling Salesman Analysis
Congkak!
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
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
:حالة استثنائيةأحمد له رجال
واحدة بينما لكل البشر رجالن