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

Feature Request: Add support for #show directives. #14

Open GregGelfond opened 1 month ago

GregGelfond commented 1 month ago

Consider the following solution to N-Queens written in CNL:

number_of_queens is a constant equal to 8.

Row goes from 1 to number_of_queens.
Column goes from 1 to number_of_queens.

Every row can have a queen_at exactly 1 column.
Every column can have a queen_at exactly 1 row.

It is prohibited that
    row R1 has a queen_at column C1 and also
    row R2 has a queen_at column C2 where
    R1 is less than R2 and
    R1 - C1 is equal to R2 - C2.

It is prohibited that
    row R1 has a queen_at column C1 and also
    row R2 has a queen_at column C2 where
    R1 is less than R2 and
    R1 + C1 is equal to R2 + C2.

The only predicate whose output I am interested in seeing is queen_at/2. It would be very useful if I could add the corresponding #show directive directly in the CNL as some sort of inline asp/assembly or directive/pragma. This could be done potentially through a special comment that adorns the rule, for example:

// #show predicate
It is prohibited that
    row R1 has a queen_at column C1 and also
    row R2 has a queen_at column C2 where
    R1 is less than R2 and
    R1 + C1 is equal to R2 + C2.

The semantics of which is to include a #show directive for the predicate defined by the following rule. This would free a person from having to have knowledge of the how specifically the predicate is compiled into ASP.