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

Distinct variables not treated as such #12

Closed GregGelfond closed 1 month ago

GregGelfond commented 1 month ago

Consider the following declarations:

Row goes from 1 to 8.
Column goes from 1 to 8.

Queen goes from 1 to 8.

Every queen can be assigned_row exactly 1 row.
Every queen can be assigned_column exactly 1 column.

The following rule:

Queen Q1 is sharing_row with queen Q2 when
    queen Q1 is assigned_row row R1 and also
    queen Q2 is assigned_row row R2.

Compiles (with the online tool) in a way that seems to violate my intuition:

sharing_row(Q2,Q2) :- 
    queen(Q1),
    assigned_row(Q1,R1),
    queen(Q2),
    assigned_row(Q2,R1),
    row(R1).

The issue here is that Q2 is used in both arguments of the predicate sharing_row/2. Intuitively, I would think it should compile as sharing_row(Q1,Q2).

Changing the CNL rule to use the another:

Queen Q1 is sharing_row with another queen Q2 when
    queen Q1 is assigned_row row R1 and also
    queen Q2 is assigned_row row R2.

Compiles to:

sharing_row(Q2,Q2) :- 
    queen(Q1),
    assigned_row(Q1,R1),
    queen(Q2),
    assigned_row(Q2,R1),
    row(R1).

This is better, but it still doesn't capture the semantics of another in that the rule is missing the inequality between Q1 and Q2.

simocaruso commented 1 month ago

Thank you for the feedback! It is now fixed and should work properly.