answer-set-programming

Newbie questions on Answer Set Programming

放肆的年华 提交于 2021-02-19 23:45:44
问题 I'm totally new to Clingo (and logic programming) and I'm looking for the best way to implement the following basic constraints: Q1. I have a predicate selected(T) where T ranges from 1 to N=5; how can I specify that exist at least one T such that selected(T) ? Q2. I have a binary predicate wrap(E,T) where E, T range from 1 to M, N; how can I specify that for each E exist at least one T such that wrap(E,T) ? Q3. How can I specify that if selected(a) OR selected(b) then selected(c) must be

Newbie questions on Answer Set Programming

时间秒杀一切 提交于 2021-02-19 23:42:38
问题 I'm totally new to Clingo (and logic programming) and I'm looking for the best way to implement the following basic constraints: Q1. I have a predicate selected(T) where T ranges from 1 to N=5; how can I specify that exist at least one T such that selected(T) ? Q2. I have a binary predicate wrap(E,T) where E, T range from 1 to M, N; how can I specify that for each E exist at least one T such that wrap(E,T) ? Q3. How can I specify that if selected(a) OR selected(b) then selected(c) must be

Brave/Cautious reasoning in clingo

*爱你&永不变心* 提交于 2021-01-29 04:29:58
问题 In Clingo guide, there are two modes called cautious and brave introduced as the follows: brave Compute the brave consequences (union of all answer sets) of a logic program. cautious Compute the cautious consequences (intersection of all answer sets) of a logic program. No more information is provided in the guide. I tried some examples and have trouble understanding the issue. I tried to run the following simple ASP program: p :- not q. q :- not p. Running Clingo with no mode parameter will

Murder puzzle in ASP

痞子三分冷 提交于 2021-01-01 06:35:10
问题 So under the tag prolog I found this puzzle (original post) and I thought: this would be even better in ASP. So I put this here as a question for anyone who wants to solve a puzzle with me. I will answer this question as soon as I found a solution myself, and I would be happy to compare my code with yours. Thank you. jean was killed on Tuesday; the only suspects are: Luc, Paul, Alain, Bernard and Louis. The rules to follow are: The murderer is somebody who has a motive to kill jean, who owns

Murder puzzle in ASP

女生的网名这么多〃 提交于 2021-01-01 06:33:49
问题 So under the tag prolog I found this puzzle (original post) and I thought: this would be even better in ASP. So I put this here as a question for anyone who wants to solve a puzzle with me. I will answer this question as soon as I found a solution myself, and I would be happy to compare my code with yours. Thank you. jean was killed on Tuesday; the only suspects are: Luc, Paul, Alain, Bernard and Louis. The rules to follow are: The murderer is somebody who has a motive to kill jean, who owns

How do I extract the trees from a graph using Answer Set Programming?

℡╲_俬逩灬. 提交于 2020-12-13 03:27:15
问题 There is an undirected graph (V,E), weights on the edges w : E → N, a target k ∈ N, and a threshold O ∈ N. Find a k-vertices tree of the graph of weight less than the threshold. In other words, select k vertices and k - 1 edges from V and E respectively such that they constitute a tree, and the sum of the weights of the selected edges are less than O. Write an ASP program that takes V , E, w, k, and O as input, and finds a selection of edges satisfying the constraints, or outputs

How do I extract the trees from a graph using Answer Set Programming?

岁酱吖の 提交于 2020-12-13 03:26:32
问题 There is an undirected graph (V,E), weights on the edges w : E → N, a target k ∈ N, and a threshold O ∈ N. Find a k-vertices tree of the graph of weight less than the threshold. In other words, select k vertices and k - 1 edges from V and E respectively such that they constitute a tree, and the sum of the weights of the selected edges are less than O. Write an ASP program that takes V , E, w, k, and O as input, and finds a selection of edges satisfying the constraints, or outputs

DLV list composition

纵饮孤独 提交于 2020-01-17 12:37:46
问题 I was wondering if there is a way in DLV for creating a list with the elements of all predicates that are true in a rule. For example, if I have the following predicates foo(a, b). foo(a, c). foo(a, e). foo(b, c). The result I am looking for should be new predicates where the first element is the first parameter of foo and the second parameter should contain a list with all the elements associated to the first parameter. Empirically: bar(a, [b,c,e]). bar(b, [c]). I know there is a way of

Tools for SAT grounding?

前提是你 提交于 2020-01-05 12:32:32
问题 In ASP (Answer Set Programming), programs are written in a higher-level declarative language and then grounded in a deterministic way to generate an ASP instance using a grounder like lparse or gringo. Are there popular grounders the SAT community uses for generating instances? In other words, is there something that could take an expression such as: vertex(a; b; c). isRed(V) \/ isBlue (V) \/ isGreen(V) :- vertex(V). and generate a DIMACS file from it? In general, how are SAT competition

Tools for SAT grounding?

感情迁移 提交于 2020-01-05 12:32:22
问题 In ASP (Answer Set Programming), programs are written in a higher-level declarative language and then grounded in a deterministic way to generate an ASP instance using a grounder like lparse or gringo. Are there popular grounders the SAT community uses for generating instances? In other words, is there something that could take an expression such as: vertex(a; b; c). isRed(V) \/ isBlue (V) \/ isGreen(V) :- vertex(V). and generate a DIMACS file from it? In general, how are SAT competition