Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 49

Knowledge

Representation (Part 2)
Logic, Rules, Frame

Knowledge Based System


Informatika-FTI-UKDW
2024

1
Logika

Objektif Aturan (Rule Based)

Frame Based

2
3
LOGIKA

4
What is a logic?

• Logics  bahasa formal untuk merepresentasikan informasi/pengetahuan


sehingga dapat digunakan untuk penarikan kesimpulan.

• Syntax  merupakan cara dan aturan untuk melakukan simbolisasi


terhadap pernyataan /kalimat.

• Semantics  merupakan makna dari sebuah kalimat.

5
Logika
Proposisional
KR in
Logic
Logika Predikat
(FOPL)
6
Syntax of Propositional Logic

• sentence  atomic sentence | complex sentence


• atomic sentence  Propositional symbol, True, False
• Complex sentence  sentence
| (sentence  sentence)
| (sentence  sentence)
| (sentence  sentence)
• Examples:
• ((P  Q)  R)
• (A  B)  (C)

7
Logika Predikat /
First Order Logic

8
First-order logic
• Propositional logic assumes the world contains facts that are true or
false.

• First-order logic assumes the world contains


• Objects: people, houses, numbers, colors, baseball games, wars, …
• Relations between objects: red, round, prime, brother of, bigger than, part of,
comes between, …
• Functions : father of, best friend, third inning of, one more than, beginning
of….

9
First Order Logic Syntax

Predicate (Object1,[object2],[object3])

Contoh :

Toni menendang bola


 Menendang (Toni, bola)
Objek Predikat Objek

10
Syntax of FOL : Basic elements

11
Models for FOL: Example

12
Quantifiers
• There are two quantifiers:
 - “for all”
• xy eats(x, y)  likes(x, y)

 - “there exits”
• x person(x)  likes(x, apples)
• x y loves(x,y)
• (xy eats(x, y)  likes(x, y))  (x = penguin)  (y=fish)

13
Unification
• Unification: The process of finding all legal substitutions that make
logical expressions look identical

14
Contoh Logika Predikat
Semua laki-laki menyukai apel. Semua Laki-laki pasti membeli semua
yang dia sukai. Toni adalah laki-laki.

Logika Predikat :

laki-laki(Toni)
15
Pertanyaan ?

16
Rule-Based

17
Bagaimana Manusia berpikir ?
 Proses berpikir manusia terlalu komplek untuk direpresentasikan dalam sebuah
algoritma
 Sebagian besar pakar mampu untuk mengekspresikan pengetahuan mereka dalam
bentuk aturan / rules
IF [condition] Then [action]

CONDITION merupakan pernyataan yang harus ada/terpenuhi/bernilai benar untuk


menjalankan ACTION
Production System : Sekumpulan aturan/rules yang digunakan untuk menjalankan
sebuah tugas/task

18
Contoh Rule
• IF Traffic light red THEN stop
• IF Traffic light green THEN move
• IF the temperature exceeds 90 degrees
THEN turn on the cooling fan.
• IF the ball red THEN I like the ball
• IF I like the ball THEN I will buy the ball

19
Rule sebagai KR Method
Rule consists of two parts: IF <antecedent/premise/condition>
THEN <consequent/conclusion/action>

IF <antecedent_1> IF <antecedent_1>


AND <antecedent_2> OR <antecedent_2>
… …
AND <antecedent_n> OR <antecedent_n>
THEN<consequent> THEN
<consequent>
IF <antecedent>
THEN<consequent_1>
<consequent_2>

<consequent_m>

Avoid to mixing conjunctions and disjunctions in the same rule!

20
Rule sebagai KR Method (2)
•The antecedent (IF part) and the consequent (Then part) incorporate two parts:
1.Linguistic object
2.Value

•Operator :
link the object and its value
Example: is, are, is not, are not, mathematical operators(>, <, =, etc.)

•Examples:
IF ‘age of the customer’ < 18
AND ‘cash withdrawal’ > Rp. 100.000,-
THEN ‘signature of the parent’ is required

IF ‘annual income’ > Rp. 20.000.000,-


THEN ‘income tax’ = ‘annual income’ * 10 / 100

21
Rule sebagai KR Method (3)

•Rules can represent: relations, recommendations, directives,


strategies, heuristics

IF the ‘fuel tank’ is empty


relation
THEN the car is dead

IF the season is autumn


AND the sky is cloudy
recomendation
AND the forecast is drizzle
THEN the advice is ‘take an umbrella’

IF the car is dead


AND the ‘fuel tank’ is empty directive
THEN the action is ‘refuel the car’

22
Rule sebagai KR Method (4)

IF the car is dead


THEN the action is ‘check the fuel tank’;
step 1 is complete

IF step 1 is complete strategy


AND the ‘fuel tank’ is full
THEN the action is ‘check the battery’;
step 2 is complete

IF the spill is liquid


AND the ‘spill pH’ < 6 heuristic
AND the ‘spill smell’ is vinegar
THEN the ‘spill material’ is ‘acetic acid’

23
Rules Example
1. IF hewan berambut or hewan menyusui THEN hewan adalah mamalia
2. IF hewan berbulu dan hewan bertelur THEN hewan adalah burung
3. IF hewan adalah mamalia and hewan makan daging THEN hewan adalah karnivora
4. IF hewan adalah karnivora and hewan berwarna kuning kecoklatan and hewan
berbintik hitam THEN hewan adalah cheetah
5. IF hewan adalah karnivora and hewan berwarna kuning kecoklatan and hewan
bergaris hitam THEN hewan adalah macan
6. IF hewan adalah burung and hewan tidak bisa terbang and hewan bisa berenang THEN
hewan adalah pinguin
7. IF hewan adalah burung and hewan memiliki sayap yang besar dan lebar THEN hewan
adalah elang laut.

24
Pertanyaan ?

25
Frame Based

26
Frame
• Frame biasa digunakan untuk merepresentasikan pengatahuan yang
bersifat umum (dimiliki oleh Sebagian besar orang).
• Sebuah frame terdiri dari sekumpulan slot dan value (Filler). Kedua
elemen ini merepresentasikan pengetahuan umum/spesifik dari
sebuah objek.
• Pewarisan properti (Property inheritance) berlaku untuk fram eyang
berbentuk hirarki.

27
Frame (2)

28
29
Frames Example

30
Class, Subclass, Instance

• Class is a collection of objects that share some common properties


• Subclasses are classes that represent subset of higher level classes
• Instance is a particular object

CLASS: Humans
Subclasses: Men, Women
Age: Unknown
Number of legs: 2
Residence: Unknown
Life expectancy: 72
31
Frame World of Humans

Class Humans

Subclasses Men Women

Instances Jack Bob Lucy Kathy

32
CLASS: Name-1
Superclass
Property-1: Value-1
Property-2: Procedure-1

Class
CLASS: Name-2
Superclass: Name-1
Property-1: Value-1 Instances

Property-2: Procedure-1
Property-3: Procedure-2

INSTANCE: Name-3
CLASS: Name-2
Property-1: Value-1
Property-2: Procedure-1
Property-3: Procedure-2

33
33
Types of Relationship

1.Generalization
• ‘a-kind-of’ or ‘is-a’ relationship between a superclass and its subclasses

CLASS: Vehicle

is- a
i s-a is-a

CLASS: Boat CLASS: Car CLASS: Airplane

Superclass: Vehicle Superclass: Vehicle Superclass: Vehicle

34
Types of Relationship (2)

2. Aggregation
• ‘a-part-of’ or ‘part-whole’ relationship
• Subclasses (components) are associated with a superclass (whole)

CLASS: Car
a-p
t-of art-
p ar o f
a- a-part-of

CLASS: Door CLASS: Engine CLASS:Transmission

Superclass: Car Superclass: Car Superclass: Car

35
Types of Relationship (3)

3. Association
• Describe some semantic relationship between different classes
• Usually appear as verbs and inherently bi-directional

CLASS: Mr. Black


s ow n
ow n belo s
ng s-to ngs
belo belongs-to owns -t o
CLASS: House CLASS: Car CLASS: Computer

Superclass:Mr.Black Superclass:Mr.Black Superclass:Mr.Black

36
Properties

 Properties:
 Describe the major features or attributes of some concept or object
 Form a set of object-attribute-value (OAV)
 Rich representation of the object

 Properties value:
 Data assigned to a given property
 Numeric, symbolic, boolean

37
Properties Values
ISNTANCE: Refrigerator
CLASS: Home Appliances
Age: 10 Initialize
Service No.: +62274797979 Database
Volume: 16 Procedure
Condition: Good Expert system
Location: Kitchen User
Power: Electricity Inheritance
Defrost cycle: On Other object

38
Inheritance
 The process by which all characteristics of a class-frame are assumed by the instance-
frame

 Hierarchical arrangement  tree


 Root : the highest level of abstraction
 Branches : lower level of abstraction
 Leaves : instance-frames

• Multiple inheritance
 In many problems it is natural to discuss objects as they relate to different worlds
 A frame inherit information from its parent, grandparent, great-grandparent, etc.

39
CLASS: ZE vehicle
[N] Weight, kg:
Inheritance
[N] Top speed, km/h:

CLASS: Electric vehicle CLASS: Solar vehicle CLASS: Muscle vehicle


Superclass: ZE vehicle Superclass: ZE vehicle Superclass: ZE vehicle
[N] Weight, kg:
[N] Top speed, km/h:
[Str] Motor:
[Str] Battery type:

CLASS: Car CLASS: Motorcylce CLASS: Scooter


Superclass: Electric vehicle Superclass: Electric vehicle Superclass: Electric vehicle
[N] Weight, kg:
[N] Top speed, km/h:
[Str] Motor:
[Str] Battery type:
[N] Range, km: 40
40
CLASS: Sedan CLASS: Van CLASS: Truck
Superclass: Car Superclass: Car Superclass: Car
[N] Weight, kg:
[N] Top speed, km/h:
[Str] Motor:
[Str] Battery type:
[N] Range, km:
[N] Payload, kg:

INSTANCE: Ford Ecostar


CLASS: Van
[N] Weight, kg: 1851
[N] Top speed, km/h: 113
[Str] Motor: 3-phase, AC induction
[Str] Battery type: Sodium sulfur
[N] Range, km: 161
41
[N] Payload, kg: 463 41
Multiple Inheritance

CLASS: Men CLASS: Employee


Age: Phone number:
Weight: Salary:

INSTANCE: Jack
Age:
Weight :
Phone number :
Salary :

42
Exception Handling

• Exception handling
 Handling an exception frame from the norm one
 When the frame has some property value unique to itself

43
CLASS: Humans
Age: Unknown
Exception Handling
Number of legs: 2
Residence: Unknown
Life expectancy: 72

CLASS: Men
Superclass: Humans
Age: Unknown
Number of legs: 2
Residence: Unknown INSTANCE: Jack
Life expectancy: 72 CLASS: Men
Mustache: True Age: 40
Number of legs: 1
Residence: Pittsburgh
Life expectancy: 72
Mustache: True
44
Pertanyaan ?

45
Tugas/Latihan 1 (Representasi
Pengetahuan)

1. Lakukan akusisi/pengumpulan pengetahuan yang terkait tugas proyek


2. Lakukan representasi pengetahuan menggunakan 2 bentuk model
representasi yang menurut kelompok anda paling cocok dengan kasus
anda.
3. Terjemahkan salah satu representasi pengetahuan ke dalam Bahasa prolog
atau Bahasa pemrograman/tools lain
4. Dikumpulkan melalui eclass paling lambat Senin 4 Maret 2024

46
Next week

Presentasi Proposal Proyek !


Disiapkan Slide untuk Presentasi

47
Proposal
Proposal proyek disusun mahasiswa dengan mengikui struktur proposal sebagai berikut :
1. Judul dan identitas kelompok
2. Latar belakang
3. Tujuan
4. Metode pengembangan sistem
5. Proses akusisi pengetahuan
6. Sumber Pengetahuan
7. Basis Pengetahuan sistem
8. Algoritma inferensi yang akan digunakan
9. Jadwal kegiatan
10. Deskripsi tugas dan tanggung jawab tiap anggota
48
Bobot Penilaian

Komponen Penilaian Kurang Cukup Baik

Permasalahan dan kelayakan topik Nilai: 0,5 Nilai: 1 Nilai: 2

Penjelasan metode pengembangan sistem Nilai: 0,5 Nilai: 1 Nilai: 2

Basis pengetahuan sistem Nilai: 0,5 Nilai: 1 Nilai: 2

Algoritma inferensi yang akan diterapkan Nilai: 0,5 Nilai: 1 Nilai: 2

Kelayakan jadwal Nilai: 0,5 Nilai: 1 Nilai: 2

49

You might also like