hexhex / core

DLVHEX solver: core system and plugin API
http://www.kr.tuwien.ac.at/research/systems/dlvhex/
GNU Lesser General Public License v2.1
24 stars 8 forks source link

Generators and short hand syntax #15

Open 0xbb opened 9 years ago

0xbb commented 9 years ago

Hello! I would like to use ASP generator rules to model a problem in dlvhex2. But I couldn't find anything about that in the documentation.

Is there a way to use generator rules with dlvhex2?

I made a mini example modeled after my requirements:

Facts:
% pair(ID, VALUE).
pair(1, 1). pair(2, 1). pair(2, 3). pair(3, 2).

id(X) :- pair(X,_).

I want to be able to write:

% all ids only having values smaller 2
all_values_smaller_2(ID) :- id(ID),
                            X <= 2: pair(ID, X).

Instead of:

exp(ID) :- pair(ID, X), X > 2.
all_values_smaller_2(ID):- not exp(ID), id(ID).

Is this possible with dlvhex2?


Additionally it also would be nice to have the Gringo short hand syntax available:

id(1..3).
pair(1,1; 2,1; 2,3; 3,2).

Greetings, Bruno

credl commented 9 years ago

Dear Bruno!

Conditional literals are supported, but currently only for ordinary atoms and not for builtin predicates. Therefore you can write your program as follows:

% pair(ID, VALUE). pair(1, 1). pair(2, 1). pair(2, 3). pair(3, 2).

id(X) :- pair(X,). set2(X) :- pair(,X), X <= 2.

% all ids only having values smaller 2 all_values_smaller_2(ID) :- id(ID), set2(X) : pair(ID, X).

Thanks for suggesting improvements!

Best regareds, Christoph

2015-06-22 13:42 GMT+02:00 Bruno Bierbaumer notifications@github.com:

Hello! I would like to use ASP generator rules to model a problem in dlvhex2. But I couldn't find anything about that in the documentation.

Is there a way to use generator rules with dlvhex2?

I made a mini example modeled after my requirements: Facts:

% pair(ID, VALUE). pair(1, 1). pair(2, 1). pair(2, 3). pair(3, 2).

id(X) :- pair(X,_).

I want to be able to write:

% all ids only having values smaller 2 all_values_smaller_2(ID) :- id(ID), X <= 2: pair(ID, X).

Instead of:

exp(ID) :- pair(ID, X), X > 2. all_values_smaller_2(ID):- not exp(ID), id(ID).

Is this possible with dlvhex2?

Additionally it also would be nice to have the Gringo short hand syntax available:

id(1..3). pair(1,1; 2,1; 2,3; 3,2).

Greetings, Bruno

— Reply to this email directly or view it on GitHub https://github.com/hexhex/core/issues/15.

0xbb commented 9 years ago

Hi Christoph! Thanks for your amazingly fast answer :)! I think this is actually solving my problem.

Greetings, Bruno