Intellektual tizimlar


Upravleniye prosessom resheniya zadachi



Download 5,12 Mb.
bet99/118
Sana10.06.2022
Hajmi5,12 Mb.
#651729
1   ...   95   96   97   98   99   100   101   102   ...   118
Bog'liq
Тафаккурли ахб техн кулланилиши 2022

1.1.6. Upravleniye prosessom resheniya zadachi.
1.1.6.1 Ispolzovaniye predikata fail. V PROLOGe realizovan mexanizm poiska s vozvratom (backtracking), pri kotorom sistema pыtayetsya otыskat vse vozmojnыye resheniya zadachi. Mexanizm vыvoda programmы zapominayet te tochki prosessa unifikasii, v kotorыx ne bыli ispolzovanы vse alternativnыye resheniya, a zatem vozvraщayetsya v eti tochki i iщyet resheniye po inomu puti.
Odnako poisk s vozvratom vыpolnyayetsya avtomaticheski tolko v tex sluchayax, kogda programma reshayet zadachu v rezultate dialoga s polzovatelem. Yesli je sel ukazana v razdele goal programmы, to poisk okanchivayetsya posle naxojdeniya pervogo resheniya zadachi. V etom sluchaye dlya vыvoda vsex resheniy ispolzuyetsya predikat fail.
Predikat fail nazыvayut otkatom posle neudachi. On vыzыvayet iskusstvennoye neuspeshnoye zaversheniye poiska, chto pozvolyayet poluchit vse vozmojnыye resheniya zadachi.
Programma 7
PREDICATES
gorod(symbol)
show
GOAL
write(“Eto goroda:”),nl,show.
CLAUSES
gorod(“moskva”). gorod(“minsk”).
gorod(“kiyev”). gorod(“omsk”).
show :- gorod(X), write(X),nl,fail.
Posle zapuska budut napechatanы vse nazvaniya gorodov. Proverte, kak budet rabotat programma bez predikata fail.
1.1.6.2. Ispolzovaniye predikata cut. Predikat otsecheniya cut oboznachayetsya s pomoщyu simvola !. On pozvolyayet poluchit dostup tolko k chasti dannыx, ustranyaya dalneyshiye poiskovыye deystviya. V obщyem vide mojno zapisat, naprimer:
R : – A,B, !, C
Eto oznachayet, chto yesli dlya seley A i V naydeno xotya bы odno resheniye, to dalneyshiy perebor vozmojnыx variantov znacheniy A i V ne nujen. Programmы 8 i 9 illyustriruyut deystviye predikata cut.
Programma 8
DOMAINS
person=symbol
PREDICATES
deti(person)
show
make_cut(person)
GOAL
write(“Eto malchiki:”),nl,show.
CLAUSES
deti(“Petya”).deti(“Vasya”).deti(“Oleg”).
deti(“Masha”).deti(“Olya”).deti(“Natasha”).
show :- deti(X),write(X),nl,make_cut(X),!.
make_cut(X) :- X=”Masha”.
Programma 8 napechatayet tolko imena malchikov.
Programma 9
PREDICATES
buy_car(symbol,symbol)
car(symbol,symbol,integer)
color(symbol,symbol)
CLAUSES
buy_car(Model,Color) :-
car(Model,Color,Price),color(Color,”svetlыy”),!,Price<25000.

Car(“moskvich”,”siniy”,12000).


Car(“jiguli”,”zelenыy”,26000).
Car(“volvo”,”siniy”,24000).
Car(“volga”,”siniy”,20000).
Car(“audi”,”zelenыy”,20000).
Color(“siniy”,”temnыy”).
Color(“zelenыy”,”svetlыy”).
Eta programma ne naydet ni odnogo resheniya, poskolku posle dorogix zelenыx «jiguley» poisk zakanchivayetsya, i boleye deshevыye «audi» ne budut naydenы.

Download 5,12 Mb.

Do'stlaringiz bilan baham:
1   ...   95   96   97   98   99   100   101   102   ...   118




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish