Being new to prolog I am reading existing code (as well as trying to write some code). Having some prior background in semweb I started to play with it and see something that is confusing me. Example assertion:
?- rdf_assert(ex:bob, rdf:type, foaf:'Person').
I also did find the following in the documentation:
Remember: Internally, all resources are atoms. The transformations
above are realised at compile-time using rules for goal_expansion/2
provided by the rdf_db library
Am I correct in assuming that somehow the library is treating the three URIs as atoms? I thought that the compiler would treat this as module_name:predicate
, but that does not seem to be the case. If that is true, could you please provide a simple example on how this could be done in prolog?
Thanks
Prolog is not a functional language. This implies 2+3
does not evaluate to 5
and is just a term that gets meaning from the predicate that processes it. Likewise, ex:bob
is just a term that has no direct relations to modules or
predicates. Only predicates such call/1 will interpret this as "call bob
in the module ex
".
Next to that, (SWI-)Prolog (most Prolog's, but not all) have term expansion that allows you to rewrite the term that is read before it is handed to the compiler. That is used to rewrite the argument of rdf/3
: each appearance of prefix:local
is expanded to a full atom. You can check that by using listing/1
on predicates that call rdf/3 using the prefix notation.
See also rdf_meta