[plt-scheme] problem with backtracking order of nested ambs

From: Joe Marshall (jmarshall at alum.mit.edu)
Date: Mon Oct 5 16:59:17 EDT 2009

I believe that the backtracking order is to the most recent (dynamically) AMB.
In your example, you could reverse the nesting of the AMBs, but I imagine
that would be much trickier in the problem you describe.

The propagator work that Sussman and Radul were doing was exploring how
to get AMB to backtrack to the nearest one that could potentially satisfy
the required dependency.  It involves a serious change to the way the compiler
compiles the code, though.

On Mon, Oct 5, 2009 at 12:58 PM, keydana at gmx.de <keydana at gmx.de> wrote:
> Hi all,
> I have a problem with the backtracking order of nested ambs which makes that
> I cannot get the result I need. I've made up a dummy example:
>  (let ((x (amb 3 5 4)))
>   (let ((result (amb (begin (assert (even? x)) x) 77)))
>     result))
> I would need amb to first try all of '(3 5 4) and only after that, take 77
> as last possible way out.
> In practice, I want to generate a list with amb, then check if every item is
> unique, if not, try all other possible ways to compose the list - and only
> there's no way to get it unique,
> decide that "ok, nearly unique is fine too", such that 2 elements may be the
> same, so try and assert that... and so on, until I can be sure that at least
> the program will not fail,
> not producing any results at all.
> I'd be glad for any hints what I'm doing wrong here...
> Thanks a lot in advance,
> Sigrid
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.