[mercury-users] Again: cc_ problem - what is Context requiring all solutions...

Ondrej Bojar oboj7042 at ss1000.ms.mff.cuni.cz
Wed Sep 5 04:08:52 AEST 2001


On Wed, 5 Sep 2001, Simon Taylor wrote:

>
> On 04-Sep-2001, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> > I got this error:
> >
> > fstag.m:081: Error: call to predicate `fstag:cc_tagmap/2' with determinism
> > `cc_nondet'
> > fstag.m:081:   occurs in a context which requires all solutions.
> >
> > And the context is:
> >
> > :- mode my_something(in, out) is cc_multi.
> >
> > my_something(In, MainOut) :-
> >   (
> >     cc_tagmap(In, TempOut),
> >     % ... make TempOut into Out
> >   ;
> >     Out = ok(calculation_skipped_for_whatever_reason)
> >   ),
> >   % ... and perform further working on Out here to obtain MainOut...
> >   % this futher part can never fail
> >
> > It is fine for me, if cc_tagmap fails, it is fine, if it succeeds as well.
> > I just do no want to backtrack it, because the ...making TempOut into Out
> > is too expensive and all possible solutions of cc_tagmap are equal for
> > this.
> >
> > Why is cc_tagmap in a context requiring all solutions? It's embedded in
> > my_something which is cc_ as well.
>
> It's a bit hard to tell with most of the code missing.
> Can "make TempOut into Out" fail?

Yes, it can.

Sorry for putting the lines away. I thought it whould be more readable
than this:

:- pred fs2taglist(fs::in, int::in, list(char)::in, list(char)::out) is
cc_multi.

fs2taglist(_FS, 0, TagL, TagL).
fs2taglist(FS, Ind, InTagL, OutTagL) :-
  (
    cc_tagmap(Ind, Path),
    extract(FS, Path, Value),
    tagmap(Path, Value, Ind, C)
  ;
    C = ('-')
  ),
  TempTagL = [C|InTagL],
  fs2taglist(FS, Ind -1, TempTagL, OutTagL).

:- pred extract(dag::in, attrpath::in, dag::out) is nondet.

:- pred cc_tagmap(int::in, attrpath::out) is nondet.
          %                                  ^^^^^^
          % This is the place, where I want cc_nondet
cc_tagmap(Ind, Path) :-
  tagmap(Path, _Value, Ind, _Char).

% and tagmap is like this:

:- pred tagmap(attrpath, dag, int, char).
:- mode tagmap(out, out, in, out).
% and also other modes
:- mode tagmap(uo, uo, in, in).
:- mode tagmap(in, in, in, out).

tagmap(cat-attrpathend, da(noun), 1, 'N').
tagmap(cat-attrpathend, da(verb), 1, 'V').
tagmap(cat-attrpathend, da(symbol), 1, 'Z').
tagmap(cat-attrpathend, da(adj), 1, 'A').
tagmap(cat-attrpathend, da(adv), 1, 'D').
tagmap(cat-attrpathend, da(prep), 1, 'R').

tagmap(agr-(gend-attrpathend), da(masc), 3, 'M').
tagmap(agr-(gend-attrpathend), da(fem), 3, 'F').
tagmap(agr-(gend-attrpathend), da(neut), 3, 'N').

...
The table then goes on, giving for *some* indices and *some* characters
different paths and dags. But for sure, for any index there is always at
most one path supplied -- and that is what cc_tagmap should extract.

Thanks, Andrew.

>
> Simon.
> --------------------------------------------------------------------------
> mercury-users mailing list
> post:  mercury-users at cs.mu.oz.au
> administrative address: owner-mercury-users at cs.mu.oz.au
> unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
> subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
> --------------------------------------------------------------------------
>

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list