|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Heisenbug in if/3Howdy all,
I'm trying to use the if/3 predicate, because I'd like to be able to backtrack over the first predicate in the test, rather than committing to it as is done with ->/3. Unfortunately, I've hit a Heisenbug in using it. My simple sample code is: bar(X) :- if(foo(3), true, true). foo(1). foo(2). foo(3). I expect it to bind X = 1 and return that answer, then X = 2 and X = 3 when I hit semicolon. When I run it, however, it gives me this error: ?- bar(X). ERROR at clause 1 of prolog:call/1 !! INSTANTIATION ERROR- call/1: expected bound value If I trace the execution, this happens: ?- trace. % Trace mode on. yes % trace ?- bar(X). (1) call:bar(_1055) ? (2) call:if(user:foo(_1055),user:true,user:true) ? (3) call:foo(_1055) ? ? (3) exit:foo(1) ? (4) call:foo(1) ? l X = 1 ? ; X = 2 ? ; X = 3 ? ; no % trace Basically, if I trace the execution of bar/1, so long as I wait until I see line (2) before leaping, I can execute without problem. If I don't (i.e., I leap at line (1) ), then it gives me the above error. I can provide additional traces if necessary, but I figure these should be sufficient. Additionally, if I turn trace back off, it goes back to the same error: ?- notrace. % Debug mode off. yes ?- bar(X). ERROR at clause 1 of prolog:call/1 !! INSTANTIATION ERROR- call/1: expected bound value X-( Additionally, I can encounter a really weird trace with the following sequence of steps (after exiting and reconsulting my test file): ?- trace. % Trace mode on. yes % trace ?- bar(X). (1) call:bar(_1055) ? l ERROR at clause 1 of prolog:call/1 !! INSTANTIATION ERROR- call/1: expected bound value (1) exception:bar(_1055) ? a % YAP execution aborted. ?- bar(X). ERROR at clause 1 of prolog:call/1 !! INSTANTIATION ERROR- call/1: expected bound value ?- trace. % Trace mode on. yes % trace ?- bar(X). (1) call:bar(_1055) ? (2) call:call(user:_1126) ? (2) exit:call(user:!) ? (1) exit:bar(_1055) ? true ? yes % trace So now I'm really feeling X-( . I am running YAP version Yap-5.1.3 . Is there anything I am doing wrong? I don't see where I'm using if/3 improperly or something, and it works when I trace it (sometimes anyways), so I'm pretty confused now. Thanks! ~Brian W. DeVries ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Yap-users mailing list Yap-users@... https://lists.sourceforge.net/lists/listinfo/yap-users |
|
|
Re: Heisenbug in if/3On 2008/10/18, at 01:17, Brian DeVries wrote: > I am running YAP version Yap-5.1.3 . The bug is also present in the latest git version of YAP 5.1.4. > Is there anything I am doing wrong? I don't see where I'm using if/3 > improperly or something, and it works when I trace it (sometimes > anyways), so I'm pretty confused now. The problem doesn't seem to be in the implementation of the if/3 predicate: ?- if(foo(X), true, true). X = 1 ? ; X = 2 ? ; X = 3 ? ; no Cheers, Paulo ----------------------------------------------------------------- Paulo Jorge Lopes de Moura Dep. of Computer Science, University of Beira Interior 6201-001 Covilhã, Portugal Office 4.3 Ext. 3257 Phone: +351 275319891 Fax: +351 275319899 Email: <mailto:pmoura@...> Home page: <http://www.di.ubi.pt/~pmoura> Research: <http://logtalk.org/> ----------------------------------------------------------------- ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Yap-users mailing list Yap-users@... https://lists.sourceforge.net/lists/listinfo/yap-users |
|
|
Re: Heisenbug in if/3Hi Brian
That was a bug in the compilation of if/3. I wrote a quick fix and I pushed it to the git repository. The patch is at: http://gitorious.org/projects/yap-git/repos/mainline/commits/38c97bd331d47baaa8a19328f336352a54128fc2 Thanks! Vitor On Sat, Oct 18, 2008 at 1:17 AM, Brian DeVries <contingencyplan@...> wrote: > Howdy all, > > I'm trying to use the if/3 predicate, because I'd like to be able to > backtrack over the first predicate in the test, rather than committing > to it as is done with ->/3. Unfortunately, I've hit a Heisenbug in > using it. > > My simple sample code is: > bar(X) :- if(foo(3), true, true). > foo(1). > foo(2). > foo(3). > > I expect it to bind X = 1 and return that answer, then X = 2 and X = 3 > when I hit semicolon. When I run it, however, it gives me this error: > > ?- bar(X). > ERROR at clause 1 of prolog:call/1 !! > INSTANTIATION ERROR- call/1: expected bound value > > If I trace the execution, this happens: > > ?- trace. > % Trace mode on. > yes > % trace > ?- bar(X). > (1) call:bar(_1055) ? > (2) call:if(user:foo(_1055),user:true,user:true) ? > (3) call:foo(_1055) ? > ? (3) exit:foo(1) ? > (4) call:foo(1) ? l > X = 1 ? ; > X = 2 ? ; > X = 3 ? ; > no > % trace > > Basically, if I trace the execution of bar/1, so long as I wait until > I see line (2) before leaping, I can execute without problem. If I > don't (i.e., I leap at line (1) ), then it gives me the above error. I > can provide additional traces if necessary, but I figure these should > be sufficient. > > Additionally, if I turn trace back off, it goes back to the same error: > > ?- notrace. > % Debug mode off. > yes > ?- bar(X). > ERROR at clause 1 of prolog:call/1 !! > INSTANTIATION ERROR- call/1: expected bound value > > X-( > > > Additionally, I can encounter a really weird trace with the following > sequence of steps (after exiting and reconsulting my test file): > ?- trace. > % Trace mode on. > yes > % trace > ?- bar(X). > (1) call:bar(_1055) ? l > ERROR at clause 1 of prolog:call/1 !! > INSTANTIATION ERROR- call/1: expected bound value > (1) exception:bar(_1055) ? a > % YAP execution aborted. > ?- bar(X). > ERROR at clause 1 of prolog:call/1 !! > INSTANTIATION ERROR- call/1: expected bound value > ?- trace. > % Trace mode on. > yes > % trace > ?- bar(X). > (1) call:bar(_1055) ? > (2) call:call(user:_1126) ? > (2) exit:call(user:!) ? > (1) exit:bar(_1055) ? > > true ? > yes > % trace > > So now I'm really feeling X-( . > > I am running YAP version Yap-5.1.3 . > > Is there anything I am doing wrong? I don't see where I'm using if/3 > improperly or something, and it works when I trace it (sometimes > anyways), so I'm pretty confused now. > > Thanks! > ~Brian W. DeVries > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Yap-users mailing list > Yap-users@... > https://lists.sourceforge.net/lists/listinfo/yap-users > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Yap-users mailing list Yap-users@... https://lists.sourceforge.net/lists/listinfo/yap-users |
| Free embeddable forum powered by Nabble | Forum Help |