Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SWI, Notation 3, C and Python

6 views
Skip to first unread message

William Waites

unread,
Feb 6, 2010, 7:11:05 PM2/6/10
to
I've been experimenting a bit with SWI Prolog, and have made some
Python bindings using Cython, mostly to learn a bit about how SWI
works.

I arrived at this looking at Notation 3, with quoted graph support and
trying to figure out how to bolt inferencing support onto rdflib, a
commonly
used RDF library for Python.

Notation 3 has constructs that look like,

{ ?X a something:Foo } => { ?X a something:Bar }

which naturally translate to prolog as something like

bar(X) := foo(X)

I would like to be able to read in rules expressed in N3 and then use
them when querying the graph, perhaps doing some forward inferencing
to pre-populate triples, etc.

I have not been able to find obvious examples of how to create clauses
like this from C. One option is to generate a prolog source file and
then
consult/1 it, but that seems needlessly circuitous.

Is there a recommended way to create "bar(X) := foo(X)" from C?

Cheers,
-w

Paulo Moura

unread,
Feb 6, 2010, 7:25:22 PM2/6/10
to
On Feb 7, 12:11 am, William Waites <wwai...@googlemail.com> wrote:
> I've been experimenting a bit with SWI Prolog, and have made some
> Python bindings using Cython, mostly to learn a bit about how SWI
> works.
>
> I arrived at this looking at Notation 3, with quoted graph support and
> trying to figure out how to bolt inferencing support onto rdflib, a
> commonly
> used RDF library for Python.

You may want to take a look at Henry, a N3 parser and reasoner for SWI-
Prolog:

http://code.google.com/p/km-rdf/wiki/Henry

Cheers,

Paulo


William Waites

unread,
Feb 6, 2010, 8:09:36 PM2/6/10
to
On Feb 7, 12:25 am, Paulo Moura <pjlmo...@gmail.com> wrote:
>
> You may want to take a look at Henry, a N3 parser and reasoner for SWI-
> Prolog:
>
> http://code.google.com/p/km-rdf/wiki/Henry

Thank you that seems very useful - better to not reinvent the
wheel.

My novice level with prolog is showing, I found something close
to the answer to my question, that you can treat ':=' as a
functor. Not sure why,

assert(bar(1)).
assert(':='(foo(X), bar(X))).
foo(X).
ERROR: toplevel: Undefined procedure: foo/1 (DWIM could not correct
goal)

I like to know why that doesn't work for interest's sake, but
Henry seems like the answer to my immediate problem...

Thanks!

-w

Paulo Moura

unread,
Feb 6, 2010, 8:49:35 PM2/6/10
to
On Feb 7, 1:09 am, William Waites <wwai...@googlemail.com> wrote:
> ...

> assert(bar(1)).
> assert(':='(foo(X), bar(X))).
> foo(X).
> ERROR: toplevel: Undefined procedure: foo/1 (DWIM could not correct
> goal)
>
> I like to know why that doesn't work for interest's sake, but
> Henry seems like the answer to my immediate problem...

Replace ':=' by ':-'.

Cheers,

Paulo

William Waites

unread,
Feb 7, 2010, 4:36:35 AM2/7/10
to
On Feb 7, 1:49 am, Paulo Moura <pjlmo...@gmail.com> wrote:
>
> Replace ':=' by ':-'.

Don't I feel silly now :P

Cheers,
-w

0 new messages