Você está na página 1de 1

1.

Matching
1) Complete a tabela, indicando as respostas do PROLOG, referentes ao mecanismo de "Matching" para os seguintes termos:
Termo 1 termo(X,Y) termo(X,Y) termo(X,X) termo(X,X) faz anos(maria,data(!",1,")) faz anos(maria,data(!",1,")) faz anos(maria,data(!",1,")) faz anos(maria,data(!",1,")) triang%&o('onto(1,1),(,'onto(2,))) triang%&o((,+,'onto(2,))) Termo 2 termo(maria,maria) Termo(maria,ana) termo(maria,maria) termo(maria,ana) faz anos(X,Y) faz anos(X,Y,#) faz anos(maria,X) faz anos(maria,data(X, , , )) Triang%&o(X,'onto(*,Y),#) triang%&o(X,'onto(*,Y),'onto(2,#)) Matching S S S N S N S $ S S Var. Instanciadas X=maria,Y=maria X=maria,Y=ana X=maria,X=maria X=maria, Y=data(!",1,") X=!" X='onto(1,1),(='onto(*,Y),#=) X=(,+='onto(*,Y),#=)

Tabela 1 - Pattern Matching

) !ois segmentos de reta podem ser definidos, em PROLOG, atra"#s das seguintes cl$usulas: "ertical%segmento%ponto%&,'1),ponto%&,' ) ) )( hori)ontal%segmento%ponto%&1,'),ponto%& ,') ) )( *) +ual a resposta ,s seguintes -uest.es: a) /0"ertical%segmento%ponto%1,1),ponto%1, ) ) )( b) /0"ertical%segmento%ponto%1,1),ponto% ,') ) )( c) /0hori)ontal%segmento%ponto%1,1),ponto% ,') ) )( d) /0hori)ontal%segmento%ponto%1,2),ponto% ,') ) )( e) /0hori)ontal%segmento%ponto%1,2),ponto% ,3) ) )( f) /0"ertical%segmento%ponto% ,*), P ) )( 4) 5radu)a para PROLOG a seguinte -uest6o: "7$ algum segmento -ue se8a simultaneamente "ertical e hori)ontal /"

Você também pode gostar