The fact that foo:nicholas
is expanded to 'http://example.org/foo#nicholas'
at compile time. For this to happen you must tell the compiler that some argument is an RDF resource. In this case you’d need
:- rdf_meta rdf_represents_member_of_class(r,t).
which tells the first argument is an RDF resource and the second is a Prolog term that may contain RDF prefix notation sub terms. See rdf_meta/1 for details.