| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| 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. |
|
#2
| |||
| |||
| 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 |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.