File: NOTES

package info (click to toggle)
gringo 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,260 kB
  • ctags: 10,755
  • sloc: cpp: 55,049; python: 629; yacc: 569; sh: 124; makefile: 23
file content (291 lines) | stat: -rw-r--r-- 6,829 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
Release Notes for gringo and clingo 4
-------------------------------------

These notes provide some hints on the language of the new gringo/clingo series
4. A full documentation of the language will be provided in the future.

A good starting point is the ASPCore 2 language specification (gringo/clingo-4
should support everything but queries) at

    https://www.mat.unical.it/aspcomp2013/ASPStandardization

Furthermore, you find ASPCore 2 encodings along with problem descriptions
in the benchmark suite of the ASP Competition 2013 at

    https://www.mat.unical.it/aspcomp2013/OfficialProblemSuite

Note that Version 4.2 still lacks support for some features like for example
reification (--reify). Call gringo with option --help to get an overview what
is supported.

Please direct all questions, bug reports, and feature requests through the
support facilities at http://sourceforge.net/p/potassco/wiki/Home

- http://sourceforge.net/mailarchive/forum.php?forum_name=potassco-users
- http://sourceforge.net/p/potassco/bugs
- http://sourceforge.net/p/potassco/feature-requests

Finally, here is a collection of small example programs, which highlight
similarities and differences between the gringo-3 and gringo-4 language, and
show some features beyond the ASPCore 2 language.

Ground Terms:
  gringo-3 and gringo-4:
    p(1). p(2). p(3).
    p(a). p(b). p(c).
    p(#infimum).
    p(#supremum).
    p("hello world!").
    p(f(1,g(2))).
    p(|20+2*-3|/2\3).
  gringo-4:
    p(#inf).
    p(#sup).

Definitions:
  gringo-3 and gringo-4:
    #const a = 1.
    #const b = a + a.
    p(b).
  gringo-3:
    p(a).
    #const a = 1.
  gringo-4:
    p(a).
    #const a = 1.

Range Terms:
  gringo-3 and gringo-4:
    p(1..10).

Normal Rules:
  gringo-3 and gringo-4:
    q(1,2). q(2,3).
    r(2,3). r(3,4).
    s(4).
    p(X) :- q(X,Y), r(Y,Z), not s(Z).
  gringo-4:
    q(1,2). q(2,3).
    r(2,3). r(3,4).
    s(4).
    p(X) :- q(X,Y); r(Y,Z); not s(Z).

Negation:
  gringo-4:
    not p(X) :- q(X,Y); r(Y,Z); not not s(Z).
    not not p(X) :- q(X,Y); r(Y,Z); not not s(Z).

Pooling:
  gringo-3 and gringo-4:
    p(a;b;c).
  gringo-3:
    p(a,b;c).
  gringo-4:
    p(a,b;c).

Projection:
  gringo-3 and gringo-4:
    p(1,2). p(1,3).
    q(X) :- p(X,_).
  gringo-4:
    p(1) :- not q(1).
    q(1) :- not p(1).
    r :- not p(_).

Extended Safety:
  gringo-4:
    p(10).
    q(X) :- p(X-1).
    r(X) :- p(X+1).
    s(X) :- p(X*2).
    t(X) :- p(2*(X-1)).

Counting Literals:
  Head:
    gringo-3:
      p(1..3).
      1 { q(X,Y): p(X): p(Y): X < Y, q(X,X): p(X) }.
    gringo-4:
      p(1..3).
      1 { q(X,Y): p(X), p(Y), X < Y; q(X,X): p(X) }.
    gringo-4:
      { p(1..3) }.
      1 { q(X,Y): p(X), p(Y), X < Y; q(X,X): p(X) }.
    gringo-4:
      2 != { p(1..3) } <= 2.
  Body:
    gringo-3:
      p(1..3).
      { q(X,Y): p(X): p(Y) }.
      q :- 1 { q(X,Y): p(X): p(Y): X < Y, q(X,X): p(X) }.
    gringo-4:
      p(1..3).
      { q(X,Y): p(X), p(Y) }.
      q :- 1 { q(X,Y): p(X), p(Y), X < Y; q(X,X): p(X) }.
    gringo-4:
      { p(1..3) }.
      { q(X,Y): p(X), p(Y) }.
      q :- 1 { q(X,Y): p(X), p(Y), X < Y; q(X,X): p(X) }.

Aggregates:
  Head:
    gringo-3:
      p(1..3). q(2..4).
      #sum [ r(X)=X: p(X): q(X) ] 1.
    gringo-4:
      p(1..3). q(2..4).
      #sum { X,r: r(X): p(X), q(X) } 1.
  Body:
    gringo-3:
      p(1..3). q(2..4).
      { r(X): p(X), r(X): q(X) }.
      s :- #sum { r(X)=X: p(X): q(X) } 1.
    gringo-4:
      p(1..3). q(2..4).
      { r(X): p(X); r(X): q(X) }.
      s :- #sum { X,r: r(X), p(X), q(X) } 1.
  Assignments:
    gringo-3:
      p(1..3).
      q(X) :- X = [ p(Y)=Y ].
    gringo-4:
      p(1..3).
      q(X) :- X = #sum { Y: p(Y) }.
  Supported Functions:
    #min, #max, #sum, #sum+, #count
    
Conditional Literals:
  Head:
    gringo-3:
      p(1..3). q(2..4).
      r(X): p(X): q(X) | a.
    gringo-4:
      p(1..3). q(2..4).
      r(X): p(X), q(X); a.
    gringo-4:
      p(1..3). q(2..4).
      r(X): p(X), q(X) | a.
    gringo-4:
      { p(1..3); q(2..4) }.
      r(X): p(X), q(X); a.
  Body:
    gringo-3:
      p(1..3). q(2..4). a.
      { r(X): p(X), r(X): q(X) }.
      s :- r(X): p(X): q(X), a.
    gringo-4:
      p(1..3). q(2..4). a.
      { r(X): p(X); r(X): q(X) }.
      s :- r(X): p(X), q(X); a.
    gringo-4:
      { p(1..3); q(2..4); a}.
      { r(X): p(X); r(X): q(X) }.
      s :- r(X): p(X), q(X); a.

Optimization:
  gringo-3:
    p(1..6).
    q(2..7).
    a.
    3 { r(X): p(X), r(X): q(X) }.
    #minimize [ r(X)=X@1: p(X): q(X), a=2@3 ].
  gringo-4:
    p(1..6).
    q(2..7).
    a.
    3 { r(X): p(X); r(X): q(X) }.
    #minimize { X@1,r: r(X), p(X), q(X); 2@3: a }.
  gringo-4:
    p(1..6).
    q(2..7).
    a.
    3 { r(X): p(X); r(X): q(X) }.
    #maximize { -X@1,r: r(X), p(X), q(X); -2@3: a }.
  gringo-4:
    p(1..6).
    q(2..7).
    a.
    3 { r(X): p(X); r(X): q(X) }.
    :~ r(X), p(X), q(X). [X@1,r]
    :~ a. [2@3]

Display Statements:
  Predicate:
    gringo-3:
      #hide.
      #show a/0.
      a. b.
    gringo-4:
      #show a/0.
      a. b.
  Term:
    gringo-4:
      #show a.
      #show 1+2.
    gringo-4:
      #show.
      #show q(X): p(X), X!=2, 2 { p(Z) }.
      { p(1..3) }.

Include Files:
  gringo-3 and gringo-4:
    #include "file.lp".

Linear Constraints (experimental; syntax subject to change):
  gringo-4:
    1 $<= $(x;y;z) $<= 3.
    1$*$x $+ 2$*$y $+ 1 $< 3 $+ $z.
  gringo-4:
    #const n=5.
    1 $<= $q(1..n) $<= n.
    $q(X) $!= $q(Y) :- X=1..n, Y=1..n, X<Y.
    X $+ $q(Y) $!= Y $+ $q(X) :- X=1..n, Y=1..n, X<Y.
    X $+ $q(X) $!= Y $+ $q(Y) :- X=1..n, Y=1..n, X<Y.

Disjoint Constraints (experimental; syntax subject to change):
  gringo-4:
    #const n=5.
    1 $<= $q(1..n) $<= n.
    #disjoint { X : $q(X)$+0 : X=1..n }.
    #disjoint { X : $q(X)$+X : X=1..n }.
    #disjoint { X : $q(X)$-X : X=1..n }.
  gringo-4:
    #const n=5.
    1 $<= $q(1..n) $<= n.
    #disjoint         { X : $q(X)$+0 : X=1..n }.
    :- not #disjoint  { X : $q(X)$+X : X=1..n }.
    not not #disjoint { X : $q(X)$-X : X=1..n }.
  gringo-4:
    1 $<= $x $<= 2.
    #disjoint{ 1:1; 2:$x }.
  gringo-4:
    $x $= 1.
    { a; b }.
    #disjoint{ a:$x:a; b:$x:b }.
  gringo-4:
    1 $<= $y $<= 2.
    { a; b }.
    #disjoint{ 1:1:a; 1:1:b; 2:$y }.
  gringo-4:
    1 $<= $(p(1..3);q(1..3)) $<= 2.
    #disjoint{ 1:$p(1..3); 2:$q(1..3) }.
  gringo-4:
    6  $<= $x $<=  7.
    35 $<= $y $<= 36.
    not #disjoint{ 1:6$*$y; 2:35$*$x }.
  gringo-4:
    1 $<= $(x;y;z) $<= 3.
    not #disjoint{ 1:2$*$x$+3$*$y; 2:2$*$y$+3$*$z; 3:2$*$z$+3$*$x }.
  gringo-4:
    X $<= $x $<= Y : b(X,Y).
    b(1,2). b(3,3). b(5,5). b(7,9).

Show Constraint Variables (experimental; syntax subject to change):
  gringo-4:
    $x $= 1.
    $y $= 1.
    $z $= 1.
    #show $x/0.
    #show $y.

PS: Roland never said the examples would make any sense.