expression(_, int(X)) --> [int(X)].
expression(_, id(N)) --> [id(N)].
expression(_, X+Y) --> expression(_,X), [sep(+)], expression(_,Y).
condition(_, A>B) --> expression(_,A), [sep(>)], expression(_,B).
condition(_, A>B) --> expression(_,A), [sep(<)], expression(_,B).
?- phrase(condition(_,X), [id(N), sep(>), int(0)]).
X = (id(N)>(int(0))).
?- phrase(condition(_,X), [id(N), sep(<), int(0)]).
infinite loop...
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.
expression(_, X+Y) --> expression(_,X), [sep(+)], expression(_,Y).
Try changing it like this. You will
need to define "expression1".
expression(_, X+Y) --> expression1(_,X), [sep(+)], expression1(_,Y).
?- phrase(condition(_,X), [id(N), sep(>), int(0)]).
X = (id(N)>(int(0))).
?- phrase(condition(_,X), [id(N), sep(<), int(0)]).
infinite loop...
I don't understand why these two behave differently:?- phrase(condition(_,X), [id(N), sep(>), int(0)]).
X = (id(N)>(int(0))).
?- phrase(condition(_,X), [id(N), sep(<), int(0)]).
infinite loop...
Perhaps because we have to backtrack out of the first clause for `condition`, and that makes us go into the infinite recursion in the third clause of `expression`?
BTW, the second argument in the head of the second clause for `condition` has a cut-and-paste error.
Hope this helps,
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
On 04/30/2018 11:31 AM, Paulo Moura wrote:
Hi,
Indeed tabling, like constraints, could use some standardization :(
But note that on YAP the '-' mode is recognized as an alias for 'first'. See:
https://github.com/vscosta/yap-6.3/blob/master/pl/tabling.yap#L310-L321
Thanks. I'll update my table :)
Isn't simple/normal (what is/should we call it?) tabling subsumed (conceptually) by mode-directed tabling?
Not sure what you mean by that. I'm not a tabling expert myself (despite
rewriting most of Benoit's code in C). Fabrizio did most of the
mode-directed tabling. In my understanding though, modes are used only
on output arguments and determines an aggregated value from all
solutions produced for that argument. The mode (min, max, first, last,
sum, etc.) determines the aggregation.
I _think_ this conflicts with tabling DCGs as (...., -, -). The first
list is not an output argument (not sure what happens or should happen
in this case) and the second should allow for multiple solutions as
different parses may consume more or less from the input. As I said, I'm
just a beginner when it comes to tabling ...
So, I think this should simply be tabled as expression//2 as Samer
proposed.
Cheers --- Jan
Cheers,
Paulo
Cheers,
Paulo
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
Cheers --- Jan
On 01/05/18 12:18, Fabrizio Riguzzi wrote:
>
> Thanks for the analysis. Remains the question whether the fact that it
> works for YAP is a bug in YAP and whether we should not raise an
> uninstantiated error if you call a tabled predicate with an instantiated
> argument in the location of a moded argument?
>
> I think it is a bug in Yap and we should not raise an exception because
> they call with a moded argument instantiated may be used to perform a check
Hmmm. Suppose we have this completely no sense making program.
:- use_module(library(tabling)).
:- table p(max).
p(1).
p(2).
p(3).
Now,
?- p(X).
X = 3.
Good! Restarting with empty tables ...
?- p(1).
true.
?- p(X).
X = 1.
Not so good :( Does this change your mind?
Cheers --- Jan
P.s. Considering that tabling is still a library, but in fact the
library is almost empty and most of the code is in C in the
kernel, wouldn't it make more sense to move tabling.pl to
the preloaded core (and provide an empty library for
compatibility?).