[mercury-users] Determinism detection for different notations.
Bartlomiej Szymczak
rhywek at gmail.com
Fri Jun 1 07:14:23 AEST 2007
Hi.
Consider the following excerpt from my code:
:-pred uselessWord(string::in) is semidet.
uselessWord("a").
uselessWord("her").
:-type yesno ---> yes ; no.
:-pred isu(string::in,yesno::out) is det.
isu(W,X):-(if uselessWord(W) then X=yes else X=no).
This code works and compiles OK. However, I find the syntax very ugly,
so at first I was trying more FOL-like notation for isu
predicate:
:-pred isu(string::in,yesno::out) is det.
isu(W,yes):-uselessWord(W).
isu(W,no):- \+uselessWord(W).
But with such a definition, I get a compiler error:
john.m:140: In `isu(in, out)':
john.m:140: error: determinism declaration not satisfied.
john.m:140: Declared `det', inferred `nondet'.
john.m:141: call to `john.uselessWord(in)' can fail.
john.m:142: Negated goal can succeed.
john.m:141: Disjunction has multiple clauses with solutions.
Clearly something is wrong, as both programs work the same way. I
suspect that the compiler doesn't see the connection between
uselessWord(W) and \+uselessWord(W). It thinks that both could succeed
or both could fail. In fact when one succeeds, the other fails and
vice-versa.
I just find the latter notation nice and the first one ugly, as in
predicate logic I would write:
uselessWord(a)
uselessWord(her)
forall W(isu(W,yes) <- uselessWord(W))
forall W(isu(W,no) <- ~uselessWord(W))
This looks like the not-compiling example. The compiling one doesn't
look like logic, as there is no if-then-else in logic. Neither there
is infix = operation in logic.
Any chance you could add better determinism detection in mercury so
that I could use my preferred notation?
Best regards,
--
Bartlomiej Antoni Szymczak
Gmail: rhywek at gmail.com
Work mail: bas at imm.dtu.dk
Student mail: s041702 at student.dtu.dk
DTU office: 321/129
DTU tel.: +4545253892
Mobile: +4520789323
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list