On 19.10.2005, at 22:05, Russ Abbott wrote:
I'll admit to being confused about the status of 'or'. 

The operational semantics of Combinator.'or' (with the convenient 'or' syntax construct) are explained in the tutorial section you pointed to. You can find more details on constraint combinaors in general and also on this or in C. Schultes book (chap 11).

The idea of this 'or' construct is actually to avoid introducing search points and to let propagation do the job instead. I only proposed it here, because you were asking for a generic version of Append which also works without search.

For your example, we can still introduce all necessary search points explicitly:

proc {MyAppend X Y Z}
   or X=nil Y=Z
   [] Xs Zs Aux in
      X=Aux|Xs Z=Aux|Zs {MyAppend Xs Y Zs}
   end
end

{Browse {SearchAll
                 proc{$ Sol}
                      A B
                   in
                      choice A = nil [] A = [a] [] A = [a b] [] A = [a b c] end
                      choice B = nil [] B = [c] [] B = [b c] [] B = [a b c] end
                      Sol=A#B
                      {MyAppend A B [a b c]}
                   end}}

Doing it all by hand may be asking too much ;-) So, you may create some function which generates a list of all possible combinations automatically and hand that list over to MakeDomain (see below) which creates all choice points:

/** %% Creates a number of choice points: in each choice point X is unified to another value in Dom (a list).
%% */
proc {MakeDomain Dom X}
   {Combinator.'choice' {List.toTuple unit
                         {Map Dom
                          fun {$ DomVal}
                             proc {$} X=DomVal end
                          end}}}
end

{Browse {SearchAll proc{$ Sol}
                      A B
                   in
A = {MakeDomain [nil [a] [a b] [a b c]]} % optionally, create full domain automatically
                      B = {MakeDomain [nil [c] [b c] [a b c]]}
                      Sol=A#B
                      {Append3 A B [a b c]}
                   end}}


I was able to see how it differed from 'choice'  and 'dis' but not how 'choice' and 'dis' differed from each other.

The 'dis' construct introduces the often so-called andorra-style disjunction. It is explained in C. Schulte, Sec 11.6. The Oz-wizards discourage using it for real-world problems, because it uses a hardwired search strategy which might not well scale for large problems. BTW, for similar reasons the wizards also discourage using 'choice' for large scale problems (e.g. CTM, p. 622).

Best,
Torsten

--
Torsten Anders
Sonic Arts Research Centre
Queen's University Belfast (UK)
www.torsten-anders.de


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to