q(a).	
q(b).
q(c).
r(a,a1).	
r(a,a2).					
r(a,a3).
r(b,b1).
r(c,c1).
	
p(X,Y) :- q(X), r(X,Y).
p(d,d1).

	
p1(X,Y) :- q(X), r(X,Y), !.	
p1(d,d1).	

	
p2(X,Y) :- q(X), !, r(X,Y).	
p2(d,d1).
p3(X,Y) :- !, q(X),  r(X,Y).	
p3(d,d1).

/*
 ?- p(X,Y).

X = a
Y = a1 ? a

X = a
Y = a2

X = a
Y = a3

X = b
Y = b1

X = c
Y = c1

X = d
Y = d1

| ?- p(d,Y).

Y = d1

| ?- p1(X,Y).

X = a
Y = a1

| ?- p1(d,Y).

Y = d1

| ?-  p2(X,Y).

X = a
Y = a1 ? a

X = a
Y = a2

X = a
Y = a3

| ?- p2(d,Y).

Y = d1

| ?- p3(X,Y).

X = a
Y = a1 ? a

X = a
Y = a2

X = a
Y = a3

X = b
Y = b1

X = c
Y = c1

| ?-  p3(d,Y).

no
*/

*/ si on ajoute q(d).

| ?- [user].
compiling user for byte code...
q(d).

user compiled, 2 lines read - 168 bytes written, 15227 ms
warning: user:1: redefining procedure q/1
         /Users/rueher/Enseignement/1_Cours/PROLOG/EnCours/Cours/coupure.pl:1: previous definition

(1 ms) yes
| ?- p2(d,Y).

no
*/

