.


:




:

































 

 

 

 





1. , .

2. , , .

3. , : .

4. , () .

.

7. ( 12)

, 1 ( B), : (, )?

DOMAINS

name, prof = symbol

PREDICATES

(prof)

(name)

(name,prof)

CLAUSES

().

(). (**)

().

().

().

(, ). (***)

(, ).

(, ).

(, ).

(, ).

(X,Y):- (*)

(X), X=, (Y)), not(Y=).

(X,Y):-

(X), X = , (Y), not(Y=),

not(Y=), not(Y=).

(X,Y):-

(X), X=, (Y), not(Y=),

not(Y=), not(Y=),

not(Y=).

(X,Y):-

(X), X=, (Y), not(Y=),

not(Y=).

(X,Y):-

(X), X=, (Y), not(Y=).

GOAL

(, ).

% (, ).

% (, ).

n

. , (, ). (*) , . X, Y . . X , X=, , , (), Y . (**) . , . , (***) (X). , , X = . , (*). , (X,Y) , (*). . , 4 , .

, ( , ). , , . , : , .

fail

fail .

, fail. fail , , , . , , : 3=2. . fail , , .

8. ( 13)

, .

PREDICATES

continent(string)

print

 

CLAUSES

continent("").

continent(" ").

continent(" ").

continent("").

continent("").

continent("").

 

print:-

continent(Continent_name),

write(Continent_name,"\n"), fail.

print.

 

GOAL

print.

print fail, . fail. .

fail , .. . , fail, . , . . , .

fail , .. .

(cut)

cut (!) .

( ). , . , cut ( ). , , , , (, ).

:

) , ;

) .

9. ( 14-15)

, , , , . , .

PREDICATES

vid(integer,integer,integer)

tip(integer,integer,integer)

suchestv(integer,integer,integer)

CLAUSES

suchestv(A,B,C):-

(A+B-C)*(A+C-B)*(B+C-A)>0,

write(" "), nl,

vid(A,B,C), tip(A,B,C). //1

suchestv(A,B,C):-

(A+B-C)*(A+C-B)*(B+C-A)<=0,

write(" "),nl.

vid(A,B,C):-

(A*A+B*B-C*C)*(A*A+C*C-B*B)*(B*B+C*C-A*A)>0,

write(""),nl.

vid(A,B,C):-

(A*A+B*B-C*C)*(A*A+C*C-B*B)*(B*B+C*C-A*A)<0,

write(""),nl.

vid(A,B,C):-

(A*A+B*B-C*C)*(A*A+C*C-B*B)*(B*B+C*C-A*A)=0,

write(""),nl.

tip(A,B,C):-

A=C, B=C,

write(""), nl.

tip(A,B,C):-

(A-B)*(B-C)*(C-A)=0,

write(""), nl.

tip(A,B,C):-

A<>B,B<>C,C<>A,

write(" "), nl.

 

GOAL

random(10,A),write(A),nl,

random(10,B),write(B),nl,

random(10,C),write(C),nl,

A*B*C<>0,

suchestv(A,B,C),

readchar(_).

random write A, B, C, . 1 .

CLAUSES , ( 16)

CLAUSES

suchestv(A,B,C):- //1

(A+B-C)*(A+C-B)*(B+C-A)>0,

write(" "), nl,

vid(A,B,C), tip(A,B,C),!.

suchestv(_,_,_):- //2

write(" "),nl.

 

vid(A,B,C):-

(A*A+B*B-C*C)*(A*A+C*C-B*B)*(B*B+C*C-A*A)>0,

write(""),nl,!.

vid(A,B,C):-

(A*A+B*B-C*C)*(A*A+C*C-B*B)*(B*B+C*C-A*A)<0,

write(""),nl,!.

vid(_, _, _):- write(""),nl. //3

 

tip(A,B,C):-

A=C, B=C, write(""),!, nl.

tip(A,B,C):-

(A-B)*(B-C)*(C-A)=0, write(""),!, nl.

tip(_, _, _):- //4

write(" "), nl.

. 2 , , 1, , . , 2 , :

suchestv(_,_,_):- //2

write(" "),nl.

( ) vid(A,B,C) tip(A,B,C) , 3 4 .

, , . , . , .

 





:


: 2017-03-18; !; : 371 |


:

:

, , . , .
==> ...

1577 - | 1408 -


© 2015-2024 lektsii.org - -

: 0.024 .