Intellektual tizimlar



Download 5,12 Mb.
bet103/118
Sana10.06.2022
Hajmi5,12 Mb.
#651729
1   ...   99   100   101   102   103   104   105   106   ...   118
Bog'liq
Тафаккурли ахб техн кулланилиши 2022

Imya

1-ye mesto

2-ye mesto

3-ye mesto

Alesha





+

Petya

+





Kolya



+



Pri opisanii etoy zadachi na PROLOGe poluchayetsya sleduyuщaya programma.


Programma 17
PREDICATES
name(symbol)
mesto(symbol)
prizer(symbol,symbol)
solution(symbol,symbol,symbol,symbol,symbol,symbol)
CLAUSES
name(alex). name(pier). name(nike).
mesto(odin). mesto(dva). mesto(tri).
prizer(X,Y):-name(X),mesto(Y),X=pier,not(Y=dva),not(Y=tri);
name(X),mesto(Y),X=nike,not(Y=tri);
name(X),mesto(Y),not(X=pier),not(X=nike).
solution(X1,Y1,X2,Y2,X3,Y3):-name(X1),name(X2),name(X3),
mesto(Y1),mesto(Y2),mesto(Y3),prizer(X1,Y1),
prizer(X2,Y2), prizer(X3,Y3),Y1<>Y2,Y2<>Y3,Y1<>Y3,
X1<>X2,X2<>X3,X1<>X3,!.
Konechno, v privedennom primere bыstreye ispolzovat tablisu dlya polucheniya resheniya. Odnako v boleye slojnыx sluchayax tablisы stanovyatsya mnogomernыmi. Rassmotrim yeщye odin primer – logicheskuyu zadachu:
«Pyatero studentov yedut na velosipedax.
Ix zovut Sergey, Boris, Leonid, Grigoriy i Viktor.
Velosipedы sdelanы v pyati gorodax: Rige, Penze, Lvove, Xarkove i Moskve.
Kajdыy iz studentov rodilsya v odnom iz etix gorodov, no ni odin iz studentov ne yedet na velosipede, sdelannom na yego rodine.
Sergey yedet na velosipede, sdelannom v Rige.
Boris rodom iz Rigi, u nego velosiped iz Penzы.
U Viktora velosiped iz Moskvы.
U Grigoriya velosiped iz Xarkova.
Viktor rodom iz Lvova.
Urojenes Penzы yedet na velosipede, delannom na rodine Leonida.
Kto iz studentov rodom iz Moskvы ?»
Dlya resheniya etoy problemы mojno predlojit sleduyuщuyu programmu:
Programma 18
DOMAINS
name=simbol
PREDICATES
student(name) \* imya studenta * \
gorod(name) \* nazvaniye goroda *\
velo(name,name) \* vladeles i «rodina» velosipeda *\
fact(name,name) \* faktы o prinadlejnosti velosipedov *\
fact1(name,name) \* faktы o meste rojdeniya *\
rodom(name,name) \* opisaniye mesta rojdeniya studenta *\
rodom_penza(name) \* opisaniye dlya urojensa Penzы *\
CLAUSES
\* 1 *\ student(X):- X=serg; X=boris; X=vict; X=grig; X=leo.
\* 2 *\ gorod(Y):- Y=penza; Y=lvov; Y=moskva; Y=xarkov; Y=riga.
\* 3 *\ fact(serg,piga).
fact(boris,penza).
fact(vict,moskva).
fact(grig,xarkov).
\* 4 *\ velo(X,Y):- student(X),gorod(Y), fact(X,Y), ! ;
student(X),gorod(Y), not( fact(X, _ )),not(fact( _, Y)).
\* 5 *\ fact1(boris,riga). fact1(vict,lvov).
\* 6 *\ rodom_penza(X) :- student(X), Z=penza,not(fact1(X,_)),
gorod(U),not(U=Z),velo(X,U),rodom(leo,U).
\* 7.1 *\ rodom(X,Z) :- student(X),gorod(Z),fact1(X,Z), ! ;
\*7.2 *\ student(X),not(X=leo),Z=penza,rodom_penza(X), !;
\* 7.3 *\ student(X),gorod(Z),not(fact1(_,Z)),X=leo,not(Z=penza),
student(K),not(fact1(K,_)),velo(K,Z);
\*7.4 *\ student(X),not(X=leo),gorod(Z),not(Z=penza),not(fact1(_,Z)),
not(fact1(X,_)), gorod(Y),not(Y=Z),velo(X,Y),
not(rodom(leo,Z)),not(rodom(leo,Y)).
Rassmotrim opisaniye faktov i pravil v etoy programme.
Pervыye dva pravila opisыvayut vozmojnыye ogranicheniya na znacheniya predikatov student i gorod. Eto neobxodimo, chtobы osuщyestvlyat dopustimыye podstanovki pri poiske resheniya.
Faktы, oboznachennыye sifroy tri, opisыvayut izvestnыye nam dannыye o tom, gde sdelanы velosipedы nekotorыx studentov.
Sifroy 4 oboznacheno pravilo, opisыvayuщyeye prinadlejnost nekotorogo velosipeda nekotoromu studentu. Pravilo sostoit iz dvux alternativnыx chastey, razdelennыx znakom “;” . Pervaya chast pravila govorit, chto student X vladeyet velosipedom Y, yesli mы znayem takoy fakt. Vtoraya chast pravila pozvolyayet delat lyubыye podstanovki, yesli eto ne protivorechit izvestnыm faktam. Predikat otsecheniya “!” zdes prekraщayet poisk novыx variantov, yesli okazalis vыpolnennыmi vse predshestvuyuщiye yemu usloviya. Eta operasiya nazыvayetsya otsecheniyem.
Sifroy 5 oboznachenы izvestnыye faktы o meste rojdeniya studentov.
Sifroy 6 opisanы predstavleniya o tom, kto iz studentov mojet bыt rodom iz Penzы. Eto ne mogut bыt Boris ili Viktor, poskolku mы znayem, chto oni rodilis v drugix gorodax, i doljen bыt student, velosiped kotorogo sdelan na rodine Leonida.
Sostoyaщyeye iz chetыrex chastey pravilo 7 opisыvayet obщiye predstavleniya o rodine kajdogo iz studentov. Vo-pervыx, mojet bыt izvesten takoy fakt i togda drugiye variantы rassmatrivat net neobxodimosti. Vtoraya chast pravila opisыvayet, kto mojet bыt rodom iz Penzы. Tretya chast pravila opisыvayet vozmojnoye mesto rojdeniya Leonida. I, nakones, chetvertaya chast pravila opisыvayet, iz kakogo goroda, krome Penzы, mogut bыt studentы, krome Leonida. Zagruziv etu programmu, mojno poluchit iskomoye resheniye.
Odnoy iz chasto vstrechayuщixsya prakticheskix zadach yavlyayetsya zadacha sostavleniya raspisaniy. Rassmotrim primer podobnoy zadachi:
«Pyat studentov doljnы poseщat leksii vsyu nedelyu, no po opredelennыm imi ustanovlennыm pravilam, a imenno:
1. Yesli prishli Andrey i Dmitriy, to Borisa bыt ne doljno, no yesli Dmitriy ne prishel, to Boris doljen bыt, a Viktor bыt ne
doljen.
2. Yesli Viktor prishel, to Andreya bыt ne doljno i naoborot.
3. Yesli Dmitriy prishel, to Grigoriya bыt ne doljno.
4. Yesli Borisa net, to Dmitriy doljen bыt, no yesli net takje i Viktora, a yesli Viktor yest, Dmitriya bыt ne doljno, no doljen bыt Grigoriy.
5. Kajdыy den studentы doljnы prixodit v raznыx sochetaniyax. Kakiye eto sochetaniya?»
Dlya resheniya etoy problemы mojet bыt predlojena programma:
Programma 19
DOMAINS
s=symbol
PREDICATES
st_A(s) st_D(s) st_B(s) st_V(s) st_G(s)
ogr1(s,s,s,s,s) ogr2(s,s,s,s,s)
spisok(s,s,s,s,s)
norm1(s,s,s,s,s) norm2(s,s,s,s,s)
norm3(s,s,s,s,s) norm4(s,s,s,s,s)
CLAUSES
st_A(A):-A=andre; A=net.
st_D(D):-D=dmitri; D=net.
st_B(B):-B=boris; B=net.
st_V(V):-V=victor; V=net.
st_G(G):-G=grig; G=net.
ogr1(andre,_,_,net,_). ogr1(net,_,_,victor,_).
ogr2(_,dmitri,_,_,net). ogr2(_,net,_,_,_).
norm1(andre,dmitri,net,_,_).
norm2(andre,net,boris,net,_).
norm3(_,dmitri,net,net,_).
norm4(_,net,net,victor,grig).
spisok(A,D,B,V,G):-st_A(A),st_D(D),st_B(B),st_V(V),st_G(G),
norm1(A,D,B,V,G),ogr1(A,D,B,V,G),ogr2(A,D,B,V,G);
st_A(A),st_D(D),st_B(B),st_V(V),st_G(G),
norm2(A,D,B,V,G),ogr1(A,D,B,V,G),ogr2(A,D,B,V,G);
st_A(A),st_D(D),st_B(B),st_V(V),st_G(G),
norm3(A,D,B,V,G),ogr1(A,D,B,V,G),ogr2(A,D,B,V,G);
st_A(A),st_D(D),st_B(B),st_V(V),st_G(G),
norm4(A,D,B,V,G),ogr1(A,D,B,V,G),ogr2(A,D,B,V,G).
st_A(A),st_D(D),st_B(B),st_V(V),st_G(G),
not(norm1(A,D,B,V,G)),not(norm2(A,D,B,V,G)),
not(norm3(A,D,B,V,G)),not(norm4(A,D,B,V,G)),
ogr1(A,D,B,V,G),ogr2(A,D,B,V,G).
Vozmojno, mojet bыt sformulirovano boleye izyaщnoye programmnoye resheniye, chem privedennoye vыshe. Pri yego poiske chitatel mojet ubeditsya, chto v podobnыx sluchayax ochen bolshoye znacheniye imeyet vыbor predikatov i pravil, kotorыye mogut opredelyatsya neyedinstvennыm obrazom. Pri neudachnom vыbore pravil mojno poluchit zavedomo lojnыye resheniya ili ischerpat resursы kompyutera pri vlojennom obraщyenii odnogo pravila k drugomu.

Download 5,12 Mb.

Do'stlaringiz bilan baham:
1   ...   99   100   101   102   103   104   105   106   ...   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