Datalog (DLV) question

7 views
Skip to first unread message

and...@acooke.org

unread,
Dec 24, 2006, 4:41:48 PM12/24/06
to
Hi,

I am a software engineer trying to describe a system of interacting
services and the messages they send, in an attempt to better understand
and improve the messaging.

I started by defining my system in SQL, but have problems due to the
lack of recursion. Prolog seems rather complex, so I thought I might
be best using Datalog. Via Wikipedia I found DLV.

However, I am now stuck. I hope this might be a suitable place to ask
for help. I want to make sure that every "call" predicate (which
describes a message being sent) has a first argument which is a
process. I used:

:- call(P, _, _, _, _), not process(P, _).

as a strong constraint, but this is unsafe. Some example data:

application(des, "Data Entry Service").
application(fis, "File Information Service").
process(p_des, "Data enters the system").
method(fis, fis_regfile, "registerFileInformation").
call(p_des, des_fis_regfile, des, fis_regfile, "register new data").
return(p_des, des_fis_regfile).
follow(p_des, des_nmg_newname, des_fis_regfile).

which indicates that during process "p_des", a message (labelled
des_fis_regfile) is sent from "des" (a service) to "fis_regfile" (a
method on a service).

How do I express this constraint (I am worried that I have errors in my
data and want to detect them)?

Am I crazy?! :o) Any help appreciated - I know some computing theory
(mainly type theory related to functional programming), but have never
used a completely declarative system before.

Thanks,
Andrew

norbert...@gmail.com

unread,
Dec 25, 2006, 3:25:33 AM12/25/06
to
and...@acooke.org wrote:
> ...

>
> I want to make sure that every "call" predicate (which
> describes a message being sent) has a first argument which is a
> process. I used:
>
> :- call(P, _, _, _, _), not process(P, _).
>
> as a strong constraint, but this is unsafe. Some example data:
>
>...

>
> How do I express this constraint (I am worried that I have errors in my
> data and want to detect them)?
>
>...


Andrew

Have a look at constraint handling rules:

http://en.wikipedia.org/wiki/Constraint_Handling_Rules

http://www.cs.kuleuven.ac.be/~dtai/projects/CHR/

Regards.

--- nef

and...@acooke.org

unread,
Dec 25, 2006, 11:41:59 AM12/25/06
to
For the record, I found that the simplest solution was to load an SQL
database with the information and use the foreign key constraints to do
the checking I wanted (this also has the advantage of being in a format
that my co-workers understand). Some stored procedures make the DB
load almost identical to the original DLV declarations.

Then I loaded the DB into DLV and did the analysis, knowing that the
data were correct.

More details at http://www.acooke.org/cute/DatalogDLV0.html

Andrew

and...@acooke.org wrote:
> Hi,
>
> I am a software engineer trying to describe a system of interacting
> services and the messages they send, in an attempt to better understand
> and improve the messaging.

[...]

and...@acooke.org

unread,
Dec 26, 2006, 11:50:23 AM12/26/06
to
Tying loose ends....

In the negated clause in my constraint I had used "_" without giving it
any thought. But all variables in a negated clause need to be bound
(at first this struck me as odd, but I believe it's because otherwise
"you" are pretty much free to choose "_" so that the constraint fails,
which makes it pointless).

The fix is trivial - pull out the field of interest via a separate
clause, so that no "_" is needed.

Thanks to Wolfgang Faber, one of the DLV developers, who took the time
to explain this over email.
Andrew

Clark VText

unread,
Dec 30, 2006, 3:11:09 PM12/30/06
to
> For the record, I found that the simplest solution was to load an SQL
> database with the information and use the foreign key constraints to
> do the checking I wanted (this also has the advantage of being in a
> format that my co-workers understand). Some stored procedures make
> the DB load almost identical to the original DLV declarations.
>

This MSDN article might interest you, though it may not be directly relevant
to your current tasks.

"Building a Rule Engine with SQL Server"

http://msdn2.microsoft.com/en-us/library/Aa964135

Clark


Reply all
Reply to author
Forward
0 new messages