potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
606 stars 81 forks source link

how to write the "different than" symbol in a .lp file ? #501

Closed aymeric75 closed 3 months ago

aymeric75 commented 3 months ago

Hi,

Somewhere in an ASP code I need to write: ` objtuple(I, (O1,O2),2) :- object(I,O1), object(I,O2), not constant(O1), not constant(O2), O1 O2.

` file.txt

For now I have writtent "!=" instead, because the ≠ creates an error:

file.lp:46:98-100: error: syntax error, unexpected <VARIABLE>

But I suspect that != is not appropriate (even if it does not create an error)

Any idea of how to write the "different than" symbol in an .lp file?

Thanks

rkaminsk commented 3 months ago

If you want to express that two terms are different, then != is the right choice.

Consider the program

p(1).
p(a).
p(3).

q(X,Y) :- p(X), p(Y), X!=Y.

which has solution

p(1) p(a) p(3) q(a,1) q(3,1) q(1,a) q(3,a) q(1,3) q(a,3)
ejgroene commented 3 months ago

Section 3.1.8 states that != is used for ‘not equals’. Did your editor fold it into ≠?

On Mon, Jun 10, 2024 at 17:28, aymeric75 @.***(mailto:On Mon, Jun 10, 2024 at 17:28, aymeric75 < wrote:

Hi,

Somewhere in an ASP code I need to write: ` objtuple(I, (O1,O2),2) :- object(I,O1), object(I,O2), not constant(O1), not constant(O2), O1 ≠ O2.

` file.txt

For now I have writtent "!=" instead, because the ≠ creates an error:

file.lp:46:98-100: error: syntax error, unexpected

But I suspect that != is not appropriate (even if it does not create an error)

Any idea of how to write the "different than" symbol in an .lp file?

Thanks

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

aymeric75 commented 3 months ago

I will use "!=" then, thanks