Inductive definition of predicates?

My aim is to dynamically generate some predicate p in code step by step in following form:

:- dynamic p/1.


get_next_element(N, N) :- not(p(N)), assert(p(N)), !.
get_next_element(N, O) :- p(N), M is N + 1, get_next_element(M, O).

get_next(N) :- get_next_element(0, N).

If I now replace the p tag by a tag illustrated by the contradiction symbol ⊥, in the code it means:

:- dynamic ⊥/1.

get_next_element(N) :- not(⊥(N)), assert(⊥(N)).
get_next_element(N) :- ⊥(N), M is N + 1, get_next_element(M).

get_next() :- get_next_element(0).

I get the following error on line :-dynamic ⊥/1:
Syntax error: Operator expected

Is their some way to deal with that problem, cause I can easily generate some static predicate eg. ⊥(N) :- N is 1.?

Try this, with a space:

:-dynamic ⊥ /1
1 Like