previous up next
Go backward to Complete Specification
Go up to Top
Go forward to Logic Evaluator
RISC-Linz logo

Logic Evaluator

pred <(m, n) <=> and(<=(m, n), not(=(m, n)));

pred divides(n, m) <=> exists(p in nat(1, m): =(*(n, p), m));

pred isPrime(p) <=>
  and(<(1, p), 
      forall(n in nat(2, -(p, 1)): not(divides(n, p))));

pred isNextPrime(n, p) <=>
  and(<=(n, p), isPrime(p),
      not(exists(q in nat(n, -(p, 1)): isPrime(q))));

fun program(n) =
  such(p in nat(n, *(2, n)): isNextPrime(n, p), p);

Author: Wolfgang Schreiner
Last Modification: October 6, 1999

previous up next