Question about using prolog equation as a variable

According to my last post in the URL:
It is possible to use the equation for example:
my_and(bool1(a, b), bool2(c, d)). when ever I want?
In my program It loaded from other file as a predicate:
some_predicate :- my_and(bool1(a, b), bool2(c, d)).
When I want to run it, I just do some_predicate.
I want to analyze it at first and extract all Atoms into a list such as [a, b, c, d].
Also for every new fact that inserted to DB, I would like to check if this equation is satisfied.
My first thought was to assign it into a variable (A) and call to a predicate which was implemented by me extract_atoms(A, List)., and then for every new fact just to do call(A).
It seems a bit problematic since the assignment is not possible.

Thank you in advance,

This does more than you need but the frameworks is what you need.

Lisprolog - Interpreter for a simple Lisp, written in Prolog. Also look at the referenced source code in GitHub.

I’m not sure how this gonna help me :confused:
My question was about the way to use this equation, as I mentioned, in 2 different ways in the same program:

  1. Extract the Atoms into a list at first.
  2. Check if new asserted rule is satisfying the equation (assume I have a lot of them, and for every new rule it should be checked).
    Note: This equation is not part of my code, it came from other file which contain it.

Main idea of my code:

equation = read_file(
atoms_list = extract_atoms(equation)
while new fact is coming:
    if the last inserted rule satisfied the equation:
        return true

Something like this (more or less).

Thank you :slight_smile:

I solve it in a simple way (I guess it was).
I read the equation (Prolog term) from a file with:

open(File, read, Stream),
read_term(Stream, Equation, [])

and with this code (Take from

split(Expression, Atomics) :-
    Expression =.. [Functor| Args],
    phrase(split_atomics(Args, Functor), Atomics).

split_atomics([], Atomic) -->
split_atomics([Head| Tail], _) -->
    split_list([Head| Tail]).

split_list([]) -->
split_list([Head| Tail]) -->
    {Head =.. [Functor| Args]},
    split_atomics(Args, Functor),

I was enable extract the atom.