dodaro / cnl2asp

A tool for converting CNL sentences to ASP rules.
https://dodaro.github.io/cnl2asp/
Apache License 2.0
1 stars 0 forks source link

Arithmetic Expression in Rule Bodies #5

Closed GregGelfond closed 1 month ago

GregGelfond commented 2 months ago

I have a solution for the famous "Zebra Puzzle" in CNL, but want to clean it up a bit. Consider the following declaration:

A house goes from 1 to 5.

Houses are essentially natural numbers here. In order to define the notion of one house being right_of another house, I had to write the following:

House 2 is right_of house 1.
House 3 is right_of house 2.
House 4 is right_of house 3.
House 5 is right_of house 4.

Ideally, I should be able to write something like:

A house H2 is right_of a house H1 when
    H2 is equal to H1 + 1. // or a simple arithmetic expression like H2 = H1 + 1.

Is arithmetic not supported in this manner?

dodaro commented 2 months ago

Hi,

this is supported, but in a slight different way:

House H2 is right_of a house H1, where H2 is equal to H1+1.

Maybe, we should update the documentation to make it clearer.

GregGelfond commented 2 months ago

Ah! And it seems that whitespace needs to be omitted (meaning that H1+1 is syntactically correct but H1 + 1 is not.

dodaro commented 2 months ago

H1 + 1 should be supported as well, this is a bug. Thank you!