Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generators and short hand syntax #15

Open
0xbb opened this issue Jun 22, 2015 · 2 comments
Open

Generators and short hand syntax #15

0xbb opened this issue Jun 22, 2015 · 2 comments

Comments

@0xbb
Copy link

0xbb commented Jun 22, 2015

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
Copy link
Member

credl commented Jun 22, 2015

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 [email protected]:

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
#15.

@0xbb
Copy link
Author

0xbb commented Jun 22, 2015

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

Greetings,
Bruno

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants