.


:




:

































 

 

 

 


Geni




. , . , : , , , , .

, , . , . , . .

, :

rule(N,CAT1,CAT2,COND).

N - ,

CAT1 - , ( ..), ;

CAT2 - , ;

COND - , .

:

cond(N, CONDTEXT),

N - ,

CONDTEXT - .

, :

rule(1,"","",[1,2])

rule(2,"","",[1,3])

rule(3,"","",[5,4,2])

rule(4,"","",[3])

rule(5,"","",[5,7])

rule(6,"","",[9,7])

rule(7,"","",[10])

rule(8,"","",[11,12])

rule(9,"","",[8,13])

rule(10,"","",[14])

rule(11,"ìëåêîïèòàþùåå","êîïûòíîå",[15])

cond(1," ")

cond(2," ")

cond(3," ")

cond(4," ")

cond(5," ")

cond(6," ")

cond(7," ")

cond(8," ")

cond(9," ")

cond(10," ")

cond(11," ")

cond(12," ")

cond(13," ")

cond(14," ")

cond(15," ")

, :

1 OND, 1 2.

, . . , , .

, . , , ,

yes(N) no(N),

N - cond.

go. , . (.. ) .

go(_, Mygoal):- /* */

not(rule(_,Mygoal,_,_)),!,nl,

write("I think it is a(n): ",Mygoal),nl,nl,

write("I was right, wasn't I? (enter y or n)"),

readchar(Ans),

evalans(Ans).

go(HISTORY, Mygoal):-

rule(RNO,Mygoal,NY,COND),

check(RNO,HISTORY, COND),

go([RNO|HISTORY],NY).

go , ( rule, ). ( evalans). , go. rule .

check, go, COND , .. , . yes(BNO) no(BNO), . , , inpq. check , . , HISTORY, , rule, :

check(RNO, HISTORY, [BNO|REST]):- yes(BNO),!,

check(RNO, HISTORY, REST).

check(_, _, [BNO|_]):- no(BNO),!,fail.

check(RNO, HISTORY, [BNO|REST]):-

cond(BNO,TEXT),

inpq(HISTORY,RNO,BNO,TEXT),

check(RNO, HISTORY, REST).

check(_, _, [ ]).

inpq , . , , yes, no why. , , . , .

inpq(HISTORY,RNO,BNO,TEXT):-

write("Is it true that ",TEXT,": "),

ROW = 14,

COL = 60,

menu(ROW,COL,7,7,[yes,no,why],"",1,CHOICE),

do_answer(HISTORY,RNO,TEXT,BNO,CHOICE).

do_answer , , , , :

do_answer(_,_,_,BNO,1):-assert(yes(BNO)), write(yes),nl. % yes

do_answer(_,_,_,BNO,2):-assert(no(BNO)), write(no),nl,fail. % no

do_answer(HISTORY,RNO,TEXT,BNO,3):-!, % why

rule(RNO, Mygoal1, Mygoal2, _),

sub_cat(Mygoal1,Mygoal2,Lstr),

concat("I try to show that: ",Lstr,Lstr1),

concat(Lstr1,"\nBy using rule number ",Ls1),

str_int(Str_num,RNO),

concat(Ls1,Str_num,Ans),

show_rule(RNO,Lls1),

concat(Ans,Lls1,Ans1),

report(HISTORY,Sng),

concat(Ans1,Sng,Answ),

display(Answ),

write(" Use Arrow Keys To Select Option "),

shiftwindow(1),

ROW = 14,COL = 60,

menu(ROW,COL,7,7,[yes,no,why],"",1,CHOICE),

do_answer(HISTORY,RNO,TEXT,BNO,CHOICE).

concat, str_int, display report:

report([],"").

report([RNO|REST],Strg):-

rule(RNO, Mygoal1, Mygoal2, _), % RNO

sub_cat(Mygoal1,Mygoal2,Lstr),

concat("I have shown that: ",Lstr,L1),

concat(L1,"By using rule number ",L2),

str_int(Str_RNO,RNO),

concat(L2,Str_RNO,L3),

concat(L3, L4),

show_rule(RNO,Str), %

concat(L4,Str,L5),

report(REST,Next_strg),

concat(L5,Next_strg,Strg).

update:

update:-

write("Name of category: "),

readln(KAT), %

KAT><"", %

write("Name of subcategory: "),

readln(SUB), SUB><"", %

readcondl(CONDL), %

getrnr(1,RNO), %

assert(rule(RNO,KAT,SUB,CONDL)), %

update.

, : " - , ", .. :

rule(RNO,"","", [BNO])

cond(BNO," "), RNO BNO - , . readcondl :

readcondl([BNO|R]):-

readln(COND), %

COND><"",!, %

getcond(BNO,COND), %

readcondl(R).

readcondl([ ]).

getcondl , , getbnr:

getcond(BNO,COND):-cond(BNO,COND),!. %

getcond(BNO,COND):-getbnr(1,BNO),

assert(cond(BNO,COND)). % Óñëîâèå äîáàâëÿåòñÿ ê áàçå äàííûõ

getbnr(N,N):-not(cond(N,_)),!.

getbnr(N,N1):-H=N+1,getbnr(H,N1).

, :

getrnr(N,N):-not(rule(N,_,_,_)),!.

getrnr(N,N1):-H=N+1,getrnr(H,N1).

Programs.

 





:


: 2015-10-01; !; : 431 |


:

:

, , . , .
==> ...

1405 - | 1243 -


© 2015-2024 lektsii.org - -

: 0.024 .