% Pt 6 % Ex 2 positive(X) :- X>0. filter(_,[],[]). filter(F,[H1|L1], [H1|L2]):- call(F,H1),!, filter(F,L1,L2). filter(F,[_|L1],L2):- filter(F,L1,L2). % ex 7 vertex(a). vertex(b). vertex(c). vertex(d). vertex(e). vertex(f). edge(a,b). edge(a,c). edge(a,d). edge(a,e). edge(a,f). edge(b,c). edge(b,e). edge(b,f). edge(c,d). edge(d,e). edge(e,f). color(rouge). color(vert). color(jaune). color(bleu). all_vertices(Vertices):- findall(V, vertex(V), Vertices). create_coloring([],[]). create_coloring([Vertex|Vertices], [c(Vertex, Color)| Colors]):- color(Color), create_coloring(Vertices, Colors). valid_coloring([c(V,C)|Colors]) . goal(Colors):- all_vertices(Vertices), create_coloring(Vertices,Colors), valid_coloring(Colors). colored_vertex(X,C):- vertex(X), color(C). ok_vertices(X,Y):- X \= Y, edge(X,Y), colored_vertex(X,C1), colored_vertex(Y,C2), C2 \= C1. goal2(Colors):- vertex(Y),findall(vertex(X),ok_vertices(X,Y),Colors).