Meta interpreter circularity in SWI Prolog

There are roughly 5 classes of predicates relevant to meta-interpretation:

  • With predicate property foreign. These are written in C (or have a C wrapper to Java/Python/…). You cannot do clause/2 and thus you cannot meta-interpret them.

  • Stuff handled by the compiler that has a clause that is exactly the same. Below is an example. You can get a clause, but this is the same as the original clause and thus you make no progress :frowning: You find the full set in boot/init.pl, currently from line 318.

    (G1, G2) :- call((G1, G2)).
    
  • Normal Prolog code that is part of the core system. They are reported as built_in.

  • Normal Prolog code from the libraries. The way to find them, as @EricGT mentioned is using the imported_from(Module) property and module_property/2, checking for class(library)

  • User code. This may be local to the module (or not in a module) or imported user code.

The first two cannot be meta-interpreted. The rest is a choice up to the user.

2 Likes