Ваша функция check_prime выдаст true даже для не простых чисел. Пример: check_prime (4) вызовет isPrime (4, 2), который объединится с первым предложением isPrime.
Пример кода, который дает вам список простых чисел, будет следующим:
% predicate to check if X has any divisors
divisible(X,Y) :- 0 is X mod Y, !.
divisible(X,Y) :- X > Y+1, divisible(X, Y+1).
%predicate to check if that number is prime by using the divisible predicate
isPrime(2) :- true,!.
isPrime(X) :- X < 2,!,false.
isPrime(X) :- not(divisible(X, 2)).
%predicate that returns the resulted list
primeList([], []). % stopping condition, when list empty
% we add current element to the resulting list if it is prime
primeList([H|T], [H|R]):- isPrime(H), !, primeList(T, R).
% otherwise, we just skip it
primeList([_|T], R):- primeList(T, R).
Запрос:? -PrimeList ([1,2,3,4,5,6,7,8,9], R). => R = [2,3,5,7]