From: Eyal D. <eya...@gm...> - 2016-02-16 18:29:39
|
Hi Ed, I think that this is because dif/2 is part of the co-routining extension and the tabling extension (YAPTab) doesn't support the co-routining extension. According to the manual (section 18) this should through an error; that it doesn't is likely a bug. I think the reason it is not supported is because tabling in YAP depends on being able to ask when one term is a variant of another. But in the presence of constraints like dif/2, two terms that are syntactic variants are no longer necessarily unifiable. Best, Eyal On Tue, Feb 16, 2016 at 11:29 AM, Edward Schwartz <esc...@ce...> wrote: > Hi all, > > I am experiencing some strange behavior when I combine tabling and dif/2. > > Here's a very simple prolog program for computing transitivity: > > % 1, 2 and 3 are on the same class. > same(1, 2). > same(1, 3). > % 4, 5, and 6 are the same class. > same(4, 5). > same(4, 6). > :- table ruleSame/2. > % Root from real facts. > ruleSame(X, Y) :- > same(X, Y). > % Commutative. > ruleSame(X, Y) :- > dif(X, Y), > ruleSame(Y, X). > % Transitive. > ruleSame(X, Y) :- > dif(X, Y), > dif(Y, Z), > dif(X, Z), > ruleSame(X, Z), > ruleSame(Z, Y). > > Basic facts are ok: > > ?- ruleSame(1,2). > yes > ?- ruleSame(1,3). > yes > ?- ruleSame(2,3). > yes > > But then some unexpected facts are generated... > > ?- ruleSame(2,4). > yes > > If I debug the evaluation of these facts, I get an extremely long trace. > > If I move the dif sub-goals after the ruleSame sub-goals, the program > works as expected. > > Is this a bug? I think it is, but hopefully I haven't overlooked > something. It seems like maybe the deferred goals from dif/2 are > interacting with tabling in a non-trivial way. > > I tested this both on YAP 6.2.2 and the current development git branch > of 6.3. Both had the same behavior. > > Thanks for any help, > > Ed > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Yap-users mailing list > Yap...@li... > https://lists.sourceforge.net/lists/listinfo/yap-users > |