Questions tagged [answer-set-programming]

Answer set programming is a declarative programming paradigm that can solve difficult search problems. It is based on the stable model (answer set) semantics of logic programming. Unlike traditional programming languages, we don’t give step by step instructions in answer set programming. It is something more like this is what I want, now you work out how to do it.

Answer set programming (ASP) is a declarative programming paradigm that can solve difficult search problems. It is based on the stable model (answer set) semantics of logic programming. Unlike traditional programming languages, we don’t give step by step instructions in answer set programming. It is something more like this is what I want, now you work out how to do it.

In answer set programming, if we can get the logic correct, ASP requires:

  • Orders of magnitude less code than imperative programming
  • Fewer points of failure
  • Less code to test
  • More productive (happier) programming life

traditional programming scheme

answer set programming scheme

161 questions
0
votes
2 answers

How to use negation to select maximum in Clingo

In prolog, we could use negation to select maximum in a tuple like: p(X), not (p(Y), Y > X). % work in Prolog but not work in Clingo How to use Clingo expression to get similar rules(if there are no bigger number than A, then A is the…
0
votes
1 answer

Clingo: logic OR in integrity constraint

For a lecture exercise, I have to represent in Answer Set Programming (we use Clingo as interpreter) a the following integrity constraint: "You have to plan the calendar of a Masterclass. Normally, the lectures are on Fridays (8 hours) and…
Lorenzo
  • 85
  • 1
  • 9
0
votes
1 answer

Answer Set Programming: how to assign numbers such that no two consecutive chars or ints are in a same password

Create an ASP model that produces all possible passwords given the following password constraints. How many password exist? Please do not comment the answer but simply tell me where my clingo solution is mistaken in the procedure. NV = 1.. N. …
0
votes
1 answer

ASP Clingo performance problem with sum-method

my current code aims to sum some values from a given database and select a combination of breakfast, lunch and dinner food. under the little database for testing you can find my code that is running and finding 42 answers for my given intervals.…
0
votes
2 answers

Find the maximum of an atom in clingo

I am a starter with clingo and I can't for the life of me figure out how to get the max value of a given atom. e.g. x(1..9). x_max(X) :- x(X), x(Y), X>Y. The result I would like to have in this case would be x_max(9).
Larkin
  • 21
  • 2
0
votes
2 answers

Answer Set Programming: Re-arrange matrix so that in no row 2 numbers are in the same order

Let's I have matrix A = 1 2 3 1 3 5 1 2 4 2 3 7 The task is to re-arrange the matrix so that in no row two elements are in the same order. For example, in row 1 and row 2 we have numbers 1 and 3 in the same order. We flip the numbers in 1 and 3 left…
0
votes
1 answer

Clingo: Compare String Literals by Order (Index)?

I have defined a color palette called tableau10 in Clingo: tableau10(blue;orange;red;teal;green;yellow;purple;pink;brown;gray). Is there a way to compare the colors by the order they appear in my color definition? (e.g., blue = 0, orange = 1, red =…
CherryQu
  • 3,343
  • 9
  • 40
  • 65
0
votes
1 answer

How to obtain count of repeated values in predicate?

I am trying to obtain the count of equal scores obtained by some player. For example, if I have score(p1, 1), score(p2, 1), score(p3, 2), I would like to obtain a new predicate occurences(Score, Count) with result(1,2) and result(2,1), since a score…
OS WL
  • 3
  • 1
0
votes
1 answer

Compare cardinality of multiple sets and get specific value from member of greatest set

I am using clingo to solve flood-it problems. I use the predicate frontier([CELL], [COLOR], [TIMESTEP]) to keep track of all cells that are neighbors of the flood. The set of frontiers could look something like this: frontier(c(1,3),2,3)…
0
votes
1 answer

What do 1<0 and 1=-1 mean in clingo/ASP?

I have never used clingo before, and I find the online documentation incomplete (I also can't post to the Potassco forums). I have a piece of clingo code with lines of rules of the format foo(L1, L2, L3) :- isa(thing,object), isa(thing,…
user2954167
  • 155
  • 1
  • 3
  • 14
0
votes
1 answer

Answer set of a program - why is the empty set not an answer set?

I'm a little confused by the definition of an answer set. S is an answer set of P if S is the least model of P. When I have a program b :- a a. Then I know my answer set has to be {a,b}, because a is a fact. What happens if I have something like a…
0
votes
1 answer

DLV predicate not being derived

I have this simple DLV program consisting of few predicates and derivations rules. One of the rules is not being activated and I have no clue why since apparently all predicates exist. I have to admit I am no expert in DLV and a bit rusty since the…
rutex
  • 137
  • 3
  • 12
0
votes
1 answer

Summing multiple values in Clingo

I am computing the sums of multiple fields in clingo: x(1,2,3). x(4,5,6). x(7,8,9). y(A,B,C) :- A = #sum { A1, B1, C1 : x(A1,B1,C1) }, B = #sum { B1, A1, C1 : x(A1,B1,C1) }, C = #sum { C1, A1, B1 : x(A1,B1,C1) }. This works. The output…
firefrorefiddle
  • 3,795
  • 20
  • 31
0
votes
1 answer

Clingo/ASP: Best way to generate characters in a story generator

I am trying to write a story generator in Clingo. I am trying to say "new characters can be born if existing characters give birth to them." I define new characters as entity(<int\>), which is the best way I could think of to representing…
Sid Datta
  • 1,110
  • 2
  • 13
  • 29
0
votes
1 answer

lparse/clingo: How to express the following in a compact form?

b(X) :- a(b(X)). c(X) :- a(c(X)). d(X) :- a(d(X)). etc. I want to express it in a compact form: F :- a(F). However, this is a syntax error. What is the correct way to do this?
Sid Datta
  • 1,110
  • 2
  • 13
  • 29