Transcript للتحميل
Chap II: Knowledge
Representation
تمثيل المعرفة تعني بناء المعرفة داخل نظام الحاسب.
يعتبر تمثيل المعرفة واستراتيجيات البحث أهم المواضيع
التي اهتم بها دارسو الذكاء االصطناعي.
1
Knowledge Representation
المقصود بتمثيل المعرفة هو جعل الحاسب يعمل ما يريده العقل
البشري بحيث يفكر كما يفكر اإلنسان ،فيأخذ المعلومات و يحللها مثل
اإلنسان..
والنظم المراد تطويرها ليست نظماً يدوية بل حاسوبيه ذات ذكاء
متطور .و من هنا ظهرت الحاجة إلى المعرفة ..و لكن كيف تمثل هذه
المعرفة؟!
في الواقع فإن المناقشة العادية التي أتعرف فيها على شخص ما ،
فإنني آخذ مجموعة من المعلومات عن هذا الشخص مثل:
اسمه،رقمه،صورته،عنوانه ..و هذه كلها معلومات اختزنها في عقلي.
و لكن في حالة الحاسب اآللي فإننا نريده أن يفكر بلغة الواقع و العقل
و ليس بأي لغة من اللغات المعروفة للحاسب..
Data, Information, Knowledge ?
Non-algorithmic
(heuristic)
Nonprogrammable
WISDOM
حكمة
KNOWLEDGE
INFORMATION
Algorithmic
DATA
programmable
3
Physical Symbol System
)Hypothesis (P2SH
نشاطًالذكاءًفيًكلًمنًاإلنسانًواآللةًيتمًتحصيلهًعبر-:
أنماط رمزية :لتمثيل خصائص المشكلة المختارة.
عمليات :لتوليد حلول ممكنة.
بحث :الختيار أفضل حل أو حلول.
4
The Example of Representation ()
The example to present pi value.
High (human)
{Abstraction}
Low (machine)
The real
number
The decimal
equivalent
3.142
exponent
Floating
point
3142 1
Computer
memory
11100010
mantissa
5
Knowledge Representation
Techniques
Rules
القواعد
Semantic
Networks
الشبكاتًالداللية
Object-Attribute
Value
TECHNIQUES
Logic
المنطق
Frames
االطارات
6
Object-Attribute-Value (OAV)
Using fact : “”صياغة المعرفة التعريفية
Used in MYCIN
•اإلشارة لقيمة خصائص معينة لشيء ما
•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. يمكن أن تكون مفردة أو متعددة القيم من سمات أو
أشياء أخرى
7
OAV Triplets Diagram (i)
Fact :=: “The chair’s color is red and priced at $
35.00 ”
RED
Color
CHAIR
Priced
Object
Attribute
$ 35.00
Value
8
OAV Triplets Diagram (ii)
Fact :=: “TIN 313 is a compulsory subject for MSc Int Sys., code
for Artificial Intelligence, and taught by Mr Yousef Salahat”
Compulsory
subject
MSc Int. Sys
TIN 313
Code
Taught
Mr Yousef
Salahat
Artificial Intelligence
9
Rules Based
القواعد :هيكل المعرفة التي تربط بعض المعلومات بمعلومات أخرى
والتي يمكن استنتاجها أو االستدالل بها لمعرفتها.
IF condition THEN action statements.
(premise
(goal
)antecedent
)consequent
•Example IF “Temperature is hot” THEN “turn on
”the air-conditioning system
مثال .لو ) الحرارة عالية( فإنه يتوجب ) تشغيل نظام التبريد(.
10
Rules Based System (I)
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.
Knowledge Base
IF ball’s color = red THEN like = ball
3
IF like = ball THEN will buy the ball
Question:
Ball’s color?
Working Memory
1
Answer: Red
Ball’s color = red
2
Like = ball
5
Will buy = ball
4
11
Rules Based System (II)
•Rule 1:
IF
x has a sore throat
AND suspect bacterial infection
THEN x has strep throat
•Rule 2:
IF
x temperature is > 37 c
THEN x has a fever
•Rule 3:
IF
x has been sick > a month
AND x has a fever
THEN suspect bacterial infection
•Patient’s
temperature =
38 c 38 حرارة المريض
•Patient has been
sick > 2 months
المريض تعبان من شهرين
•Patient has a sore
throat
المريض لديه التهاب حلق
•Conclusion ?
Patient has
Strep throat
المريض لديه بكتيريا في الحلق
12
Semantic Networks
هي إحدى الطرق المستخدمة في تمثيل المعرفة في النظم الخبيرة ..وهي
عبارة عن تمثيل المعرفة على شكل تركيب شبكي ..
كلًشبكةًداللية:
•مجموعةًمنً Objectsتدعىًعقدً..nodes
•مجموعةًمنًالروابطً Linkتربطًبينً..nodes
•المعالجةًاالستثنائيةً Exceptional handling
بعض االستثناءات لحاالت معينة ” كل الطيور قادرة على الطيران والنعامة
طير“ هل يمكن للنعامة أن تطير؟
13
The Example of Semantic
Networks (Bird)
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.
has
is-a
Parrot
الببغاء
is-a
Bird
طائر
Animal
حيوان
travel
Fly
يطير
Walk
مشي
“exceptional
handling”
Ostrich
النعامة
travel
Wings
أجنحة
Air
الهواء
Breathe
يتنفس
14
Frames
و هي إحدى الطرق المستخدمة لتمثيل المعرفة في النظم الخبيرة و هي
طريقة خاصة لكتابة بيانات المعرفة على شكل هيكل عام يحتوي إطارات.
•Extension : schemas and basic to OOP
خصائصًعامةًلبعضًاألشياءًالعامةًمثال .إطارً •Class frame
التصنيفًطائرًيشيرًإلىًخصائصًعامةًللطائر.
لوصفًخصائصًفريدةًمنًإطارًالتصنيفً •Instance frame
مثال .الصنفًنعامةًمنًإطارًالصنفًطائر
15
Frames Structure
Frame Name: BIRD
Frame Name: OSTRICH
Properties:
Color = unknown
Wings = 2
Flies = True
Class Name: BIRD
Properties:
Color = brown/dark
Wings = 2
Flies = False
16
Logicالمنطقًالرياضي
.أقدم تمثيل موجود •The oldest representation existed
•Implemented using PROLOG, LISP programming
language.
• تمثيل المعرفة وبناء قواعدها يتطلب تحويل هذه الجمل إلى صيغ يسهل تمثيلها
داخل أنظمة الحاسب.
•والجمل وفق المنطق االفتراضي Propositional Logicأما أن تكون جمل
بسيطة أو جمل مركبة.
17
General
Name
Formal
Name
Symbols
Not
Negation
And
Conjunction
Or
Disjunction
If…
Then/Implies
Conditional
If and only if
Biconditional
وإذ أخذنا المعاني التي
نستخلصها من هذه
الجمل نجدها أما أن
(تقدم إخبارا ) حقائق
وهذه،أو قواعد
الحقائق أو القواعد أما
أن تكون صحيحة أو
True or ) خاطئة
.(False
Logical Operators
18
Factsالحقائق
وهي الجمل التي تصف شيئا ما أو تخبر عن شيء ما سواء كانت هذه الجملة
جملة اسمية أو فعلية أو شبه جملة ،على سبيل المثال:
•الذكاء االصطناعي مقرر حاسب
Artificial intelligence is a computer system
•القط حيوان Cat is an animal
وقدًتكونًالحقيقةًمركبة
•أم احمد متزوجة من والد خالد Ahmed mother is married to Khalid father
وهذه الحقائق كلها حقائق صحيحة )(True
•أما إذا أخذنا الجملة التالية Cat is human :
فهي حقيقة خاطئة )(false
19
Rulesالقواعد
وهي الجمل التي يمكن تعميمها أو تطبيقها على مجموعة من األشياء ويلزم
تطبيقها توفر شرط أو مجموعة شروط.
•ما يكسب بسهولة يضيع بسهولة Easy come easy go
•لكل سؤال جواب every way has an answer
قدًتكونًالقاعدةًفيًصورةًجملةً ifعلىًسبيلًالمثال:
•إذا كان الحيوان يعطي حليبا أذا الحيوان من ذوات الثدييات if animal give
milk it is a mammal
20
Predicate Calculus Logic
(FOPL)
:•والشكلًالعامًلتركيبًالجملًوفقًالمنطقًالرياضيًهو
operator (variables_1, variables_2,…)
EXAMPLES:
COMPUTER_COURSE(ARTIFICIAL_INTELLEGIENCE)
ANIMAL(CAT)
21
جدول :الرموز المستخدمة في التمثيل الرياضي للمنطق
الرمزًSymbol
22
المعنىًMeaning
لكلFor All
يوجد Exist
نفي NOT
وAnd
v
أو OR
أذا Then
gt
أكبر من Greater than
lt
أقل من Less than
ge
أكبر من أو يساويGreater than or equal
le
أقل من أو يساويLess than or equal
=
يساوي equal
Predicate Calculus Logic
(FOPL)
•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))]
23
The Example of FOPL
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)
24
The Truth Table
P
Q
NOT
(P)
AND
P^Q
OR
PvQ
Implies
PQ
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
Operation
Consider P and Q as a propositional statement.
Show the result when (P ^ (P Q)) Q
P
Q
PQ
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
Implementing Propositional
Logic
“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
P
Q
PQ
T
T
F
F
T
F
T
F
T
F
T
T
•Equivalence to P Q
27
The Example of PROLOG
Language
My name is Ahmad bin Abdullah. My father is Abdullah bin
Abdul Karim.
Code
son(ahmad,abdullah).
son(abdullah,abdul_karim).
grandfather(X,Y):fahter(X, Somebody),
fahter(Somebody, Y).
father(X,Y):son(Y,X).
Output
?- grandfather(X,Y).
X = abdul_karim ,
Y = ahmad ;
?- father(X,Y).
X = abdullah ,
Y = ahmad ;
X = abdul_karim ,
Y = abdullah
28
The Application from
PROLOG Language
Congkak!
Games: Reversi
Travelling Salesman
Analysis
29
الشكلًالتاليًيعبرًعنًشبكةًدالليةًلعالقةً
أسرية .يمكنناًمنًخاللًهذاًالشكلًأنًنعبر
عنًهذهًالعالقاتًقيًصورتين:
.1جملًوفقًالمنطقًالرياضي
.2أطرًجدوليه
Mammals
Subset-of
legs
2
Person
HasMother
Subset of
Subset-of
Male
Person
Female
Person
Member of
Member of
Sister of
Mariam
Ahmad
legs
1
الشكل التالي يعبر عن شبكة داللية لعالقة أسرية .يمكننا من خالل هذا الشكل أن نعبر عن هذه
العالقات قي صورتين:
.1جمل وفق المنطق الرياضي
.2أطر جدولية
Sister_of(Mariam,Ahmed)
حالة استثنائية:
أحمد له رجال واحدة
بينما لكل البشر رجالن
Legs(Ahmed)=1
Member_of(Mariam,Female_Person)
اإلطارًالخاصًب Person
Person:
Subset of : Mammal
Legs: 2
Has Mother : Female Person
31
اإلطارًالخاصًب Ahmed
Ahmed :
Member of : Male Person
Legs: 1
Has Sister : Mariam