Finding the difference in consequences between two logic programs

This is a discussion on Finding the difference in consequences between two logic programs within the PROLOG forums in Programming Languages category; Hello, Given two logic programs LP1 and LP2, I would like to generate consequences of LP1 that are not consequences of LP2. Is there an efficient way of finding these consequences? A basic solution is quite simple to express: lp1_and_not_lp2(X) :- lp1(X), \+ lp2(X). but as the programs become more complex, the inefficiency of this approach becomes a problem. It seems to be quite a general problem - is there any theory I should know about, and is another setting (e.g. CLP / answer set programming) more suited than Prolog? In my case, LP1 and LP2 are closely related (to ...

Go Back   Application Development Forum > Programming Languages > PROLOG

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-01-2008, 07:20 AM
Zoubidoo
Guest
 
Default Finding the difference in consequences between two logic programs

Hello,

Given two logic programs LP1 and LP2, I would like to generate
consequences of LP1 that are not consequences of LP2. Is there an
efficient way of finding these consequences? A basic solution is
quite simple to express:

lp1_and_not_lp2(X) :- lp1(X), \+ lp2(X).

but as the programs become more complex, the inefficiency of this
approach becomes a problem.

It seems to be quite a general problem - is there any theory I should
know about, and is another setting (e.g. CLP / answer set programming)
more suited than Prolog?

In my case, LP1 and LP2 are closely related (to get LP2 just add/
remove a few clauses from LP1) - does this help make the problem
easier to solve?

Thanks for any pointers!
Zoubidoo


A simple example:

% LP1
lp1(X) :- lp1_p(X).
lp1_p(a).
lp1_p(b).

% LP2 Removed p(b) and added p(c)
lp2(X) :- lp2_p(X).
lp2_p(a).
lp2_p(c).

lp1_and_not_lp2(X) :- lp1(X), \+ lp2(X).

The only solution here is X = b.
Reply With Quote
  #2  
Old 07-01-2008, 03:23 PM
Chip Eastham
Guest
 
Default Re: Finding the difference in consequences between two logic programs

On Jul 1, 7:20*am, Zoubidoo <Stanc...@gmail.com> wrote:
> Hello,
>
> Given two logic programs LP1 and LP2, I would like to generate
> consequences of LP1 that are not consequences of LP2. *Is there an
> efficient way of finding these consequences? *A basic solution is
> quite simple to express:
>
> lp1_and_not_lp2(X) :- lp1(X), \+ lp2(X).
>
> but as the programs become more complex, the inefficiency of this
> approach becomes a problem.
>
> It seems to be quite a general problem - is there any theory I should
> know about, and is another setting (e.g. CLP / answer set programming)
> more suited than Prolog?
>
> In my case, LP1 and LP2 are closely related (to get LP2 just add/
> remove a few clauses from LP1) - does this help make the problem
> easier to solve?
>
> Thanks for any pointers!
> Zoubidoo
>
> A simple example:
>
> % LP1
> lp1(X) :- lp1_p(X).
> lp1_p(a).
> lp1_p(b).
>
> % LP2 * Removed p(b) and added p(c)
> lp2(X) :- lp2_p(X).
> lp2_p(a).
> lp2_p(c).
>
> lp1_and_not_lp2(X) :- lp1(X), \+ lp2(X).
>
> The only solution here is X = b.


Without "special knowledge" of predicates
lp1/1 and lp2/1, the opportunities for
improving on your basic solution seem
limited.

One alternative, if the solutions to lp1/1
are finite, is to form a list of these L
via findall/3, then process that list to
knock out those which solve lp2/1 as well.

Such an approach might be especially
attractive if the comparison were to
involve more than two predicates.

regards, chip
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:04 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.