iscc: add before and after operations
[barvinok.git] / doc / isl.tex
blob0a6ff2ed854f322572d2b7b0aa98607cf769bd4a
1 \section{\protect\isl/ interface}
3 \let\llt\prec
4 \let\lle\preccurlyeq
5 \let\lgt\succ
7 \subsection{Library}
9 The \barvinok/ library currently supports only a few
10 functions that interface with the \isl/ library.
11 In time, this interface will grow and is set to replace
12 the \PolyLib/ interface.
13 For more information on the \isl/ data structures, see
14 the \isl/ user manual.
16 \begin{verbatim}
17 __isl_give isl_pw_qpolynomial *isl_set_card(__isl_take isl_set *set);
18 __isl_give isl_union_pw_qpolynomial *isl_union_set_card(
19 __isl_take isl_union_set *uset);
20 \end{verbatim}
21 Compute the number of elements in an \ai[\tt]{isl\_set}
22 or \ai[\tt]{isl\_union\_set}.
23 The resulting \ai[\tt]{isl\_pw\_qpolynomial}
24 or \ai[\tt]{isl\_union\_pw\_qpolynomial} has purely parametric cells.
26 \begin{verbatim}
27 __isl_give isl_pw_qpolynomial *isl_map_card(__isl_take isl_map *map);
28 __isl_give isl_union_pw_qpolynomial *isl_union_map_card(
29 __isl_take isl_union_map *umap);
30 \end{verbatim}
31 Compute a closed form expression for the number of image elements
32 associated to any element in the domain of the given \ai[\tt]{isl\_map}
33 or \ai[\tt]{isl\_union\_map}.
34 The union of the cells in the resulting \ai[\tt]{isl\_pw\_qpolynomial}
35 is equal to the domain of the input \ai[\tt]{isl\_map}.
37 \begin{verbatim}
38 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sum(
39 __isl_take isl_pw_qpolynomial *pwqp);
40 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sum(
41 __isl_take isl_union_pw_qpolynomial *upwqp);
42 \end{verbatim}
43 Compute the sum of the given piecewise quasipolynomial over
44 all integer points in the domain. The result is a piecewise
45 quasipolynomial that only involves the parameters.
46 If, however, the domain of the piecewise quasipolynomial wraps
47 a relation, then the sum is computed over all integer points
48 in the range of that relation and the domain of the relation
49 becomes the domain of the result.
51 \begin{verbatim}
52 __isl_give isl_pw_qpolynomial *isl_map_apply_pw_qpolynomial(
53 __isl_take isl_map *map, __isl_take isl_pw_qpolynomial *pwqp);
54 __isl_give isl_union_pw_qpolynomial *isl_union_map_apply_union_pw_qpolynomial(
55 __isl_take isl_union_map *umap,
56 __isl_take isl_union_pw_qpolynomial *upwqp);
57 \end{verbatim}
58 Compose the given map with the given piecewise quasipolynomial.
59 That is, compute the sum over all elements in the intersection
60 of the range of the map and the domain of the piecewise quasipolynomial
61 as a function of an element in the domain of the map.
63 \subsection{Calculator}
65 The \ai[\tt]{iscc} calculator offers an interface to some
66 of the functionality provided by the \isl/ and \barvinok/
67 libraries.
68 The supported operations are shown in \autoref{t:iscc}.
69 Note that when an operation requires an argument of a certain
70 type, a binary list with the first element of the required type
71 may also be used instead.
72 Here are some examples:
73 \begin{verbatim}
74 P := [n, m] -> { [i,j] : 0 <= i <= n and i <= j <= m };
75 card P;
77 f := [n,m] -> { [i,j] -> i*j + n*i*i*j : i,j >= 0 and 5i + 27j <= n+m };
78 sum f;
79 s := sum f;
80 s @ [n,m] -> { [] : 0 <= n,m <= 20 };
82 f := [n] -> { [i] -> 2*n*i - n*n + 3*n - 1/2*i*i - 3/2*i-1 :
83 (exists j : 0 <= i < 4*n-1 and 0 <= j < n and
84 2*n-1 <= i+j <= 4*n-2 and i <= 2*n-1 ) };
85 ub f;
86 u := (ub f)[0];
87 u @ [n] -> { [] : 0 <= n <= 10 };
89 m := [n] -> { [i,j] -> [i+1,j+1] : 1 <= i,j < n;
90 [i,j] -> [i+1,j-1] : 1 <= i < n and 2 <= j <= n };
91 m^+;
92 (m^+)[0];
94 codegen [N] -> { A[i] -> [i,0] : 0 <= i <= N; B[i] -> [i,1] : 1 <= i <= N };
96 { [k] -> [i] : 1 <= i <= k } . { [n] -> 2 * n : n >= 1 };
98 { [m] -> [c] : 1 <= c <= m } . { [k] -> max((3 * k + k^2)) : k >= 1 };
99 \end{verbatim}
101 \bottomcaption{{\tt iscc} operations. The variables
102 have the following types,
103 $s$: set,
104 $m$: map,
105 $q$: piecewise quasipolynomial,
106 $f$: piecewise quasipolynomial fold,
107 $l$: list,
108 $i$: integer,
109 $b$: boolean,
110 $S$: string,
111 $o$: object of any type
113 \label{t:iscc}
114 \tablehead{
115 \hline
116 Syntax & Meaning
118 \hline
120 \tabletail{
121 \multicolumn{2}{r}{\small\sl continued on next page}
124 \tablelasttail{}
125 \begin{supertabular}{p{0.35\textwidth}p{0.6\textwidth}}
126 $s_2$ := \ai[\tt]{aff} $s_1$ & affine hull of $s_1$
128 $m_2$ := \ai[\tt]{aff} $m_1$ & affine hull of $m_1$
130 $q$ := \ai[\tt]{card} $s$ &
131 number of elements in the set $s$
133 $q$ := \ai[\tt]{card} $m$ &
134 number of elements in the image of a domain element
136 $s_2$ := \ai[\tt]{coalesce} $s_1$ &
137 simplify the representation of set $s_1$ by trying
138 to combine pairs of basic sets into a single
139 basic set
141 $m_2$ := \ai[\tt]{coalesce} $m_1$ &
142 simplify the representation of map $m_1$ by trying
143 to combine pairs of basic maps into a single
144 basic map
146 $q_2$ := \ai[\tt]{coalesce} $q_1$ &
147 simplify the representation of $q_1$ by trying
148 to combine pairs of basic sets in the domain
149 of $q_1$ into a single basic set
151 $f_2$ := \ai[\tt]{coalesce} $f_1$ &
152 simplify the representation of $f_1$ by trying
153 to combine pairs of basic sets in the domain
154 of $f_1$ into a single basic set
156 \ai[\tt]{codegen} $s$ &
157 generate code for the given domain.
158 This operation is only available if \ai[\tt]{CLooG}
159 support was compiled in.
161 \ai[\tt]{codegen} $m$ &
162 generate code for the given scattering function.
163 This operation is only available if \ai[\tt]{CLooG}
164 support was compiled in.
166 $s_3$ := $s_1$ \ai[\tt]{cross} $s_2$ &
167 Cartesian product of $s_1$ and $s_2$
169 $m_3$ := $m_1$ \ai[\tt]{cross} $m_2$ &
170 Cartesian product of $m_1$ and $m_2$
172 $s$ := \ai[\tt]{deltas} $m$ &
173 the set $\{\, y - x \mid x \to y \in m \,\}$
175 $s$ := \ai[\tt]{dom} $m$ &
176 domain of map $m$
178 $s$ := \ai[\tt]{dom} $q$ &
179 domain of piecewise quasipolynomial $q$
181 $s$ := \ai[\tt]{dom} $f$ &
182 domain of piecewise quasipolynomial fold $f$
184 $s$ := \ai[\tt]{ran} $m$ &
185 range of map $m$
187 $m$ := \ai[\tt]{identity} $s$ &
188 identity relation on $s$
190 $s_2$ := \ai[\tt]{lexmin} $s_1$ &
191 lexicographically minimal element of $s_1$
193 $m_2$ := \ai[\tt]{lexmin} $m_1$ &
194 lexicographically minimal image element
196 $s_2$ := \ai[\tt]{lexmax} $s_1$ &
197 lexicographically maximal element of $s_1$
199 $m_2$ := \ai[\tt]{lexmax} $m_1$ &
200 lexicographically maximal image element
202 $o$ := \ai[\tt]{read} {\tt "}{\it filename}{\tt"} &
203 read object from file
205 $s_2$ := \ai[\tt]{sample} $s_1$ &
206 a sample element of the set $s_1$
208 $m_2$ := \ai[\tt]{sample} $m_1$ &
209 a sample element of the map $m_1$
211 \ai[\tt]{source} {\tt "}{\it filename}{\tt"} &
212 read commands from file
214 $q_2$ := \ai[\tt]{sum} $q_1$ &
215 sum $q_1$ over all integer points in the domain of $q_1$,
216 or, if the domain of $q_1$ wraps a map, over all integer
217 points in the range of the wrapped map.
219 $l$ := \ai[\tt]{ub} $q$ &
220 compute an
221 upper bound on the piecewise quasipolynomial $q$ over
222 all integer points in the domain of $q$
223 and return a list containing the upper bound
224 and a boolean that is true if the upper bound
225 is known to be tight.
226 If the domain of $q$ wraps a map, then the upper
227 bound is computed over all integer points in
228 the range of the wrapped map instead.
230 $l$ := \ai[\tt]{vertices} $s$ &
231 a list of vertices of the rational polytope defined by the same constraints
232 as $s$
234 $s$ := \ai[\tt]{wrap} $m$ &
235 wrap the map in a set
237 $m$ := \ai[\tt]{unwrap} $s$ &
238 unwrap the map from the set
240 $m_4$ := \ai[\tt]{any} $m_1$ \ai[\tt]{before} $m_2$ \ai[\tt]{under} $m_3$ &
241 compute a map from any element $x$ in the domain of $m_1$
242 to any element $y$ in the domain of $m_2$
243 such that their images $m_1(x)$ and $m_2(y)$ overlap
244 and such that $m_3(x) \llt m_3(y)$.
246 $l$ := \ai[\tt]{last} $m_1$ \ai[\tt]{before} $m_2$ \ai[\tt]{under} $m_3$ &
247 compute a map that contains for any element $y$ in the domain of $m_2$
248 a mapping from the lexicographically last element $x$ in the domain of $m_1$
249 (according to the schedule $m_3$) to $y$
250 such that $m_1(x)$ and $m_2(y)$ overlap and such that $m_3(x) \llt m_3(y)$.
251 Return a list containing this map and the set of elements in the domain of
252 $m_2$ for which there is no corresponding element in the domain of $m_1$.
254 $m_5$ := \ai[\tt]{any} $m_1$ \ai[\tt]{last} $m_2$ \ai[\tt]{before} $m_3$
255 \ai[\tt]{under} $m_4$ &
256 compute a map that contains for any element $y$ in the domain of $m_3$
257 a mapping from the lexicographically last element $x$ in the domain of $m_2$
258 (according to the schedule $m_4$) to $y$
259 such that $m_2(x)$ and $m_3(y)$ overlap and such that $m_4(x) \llt m_4(y)$
260 as well as from any element $z$ in the domain of $m_1$ such that
261 $m_1(z)$ and $m_3(y)$ overlap, $m_4(z) \llt m_4(y)$ and such that there
262 is no $x$ in the domain of $m_2$ with
263 $m_2(x) \cap m_3(y) \ne \emptyset$ and $m_4(z) \llt m_4(x) \llt m_4(y)$.
265 $s_3$ := $s_1$ \ai{$+$} $s_2$ & union
267 $m_3$ := $m_1$ \ai{$+$} $m_2$ & union
269 $q_3$ := $q_1$ \ai{$+$} $q_2$ & sum
271 $f_2$ := $f_1$ \ai{$+$} $q$ & sum
273 $f_2$ := $q$ \ai{$+$} $f_1$ & sum
275 $S_3$ := $S_1$ \ai{$+$} $S_2$ & concatenation
277 $S_2$ := $o$ \ai{$+$} $S_1$ &
278 concatenation of stringification of $o$ and $S_1$
280 $S_2$ := $S_1$ \ai{$+$} $o$ &
281 concatenation of $S_1$ and stringification of $o$
283 $s_3$ := $s_1$ \ai{$-$} $s_2$ & set difference
285 $m_3$ := $m_1$ \ai{$-$} $m_2$ & set difference
287 $q_3$ := $q_1$ \ai{$-$} $q_2$ & difference
289 $s_3$ := $s_1$ \ai{$*$} $s_2$ & intersection
291 $m_3$ := $m_1$ \ai{$*$} $m_2$ & intersection
293 $q_3$ := $q_1$ \ai{$*$} $q_2$ & product
295 $m_2$ := $m_1$ \ai{$*$} $s$ & intersect domain of $m_1$ with $s$
297 $q_2$ := $q_1$ \ai{$*$} $s$ & intersect domain of $q_1$ with $s$
299 $f_2$ := $f_1$ \ai{$*$} $s$ & intersect domain of $f_1$ with $s$
301 $s_2$ := $m$($s_1$) & apply map $m$ to set $s_1$
303 $m_3$ := $m_1$ \ai[\tt]{.} $m_2$ & join of $m_1$ and $m_2$
305 $m_3$ := $m_1$ \ai[\tt]{before} $m_2$ & join of $m_1$ and $m_2$
307 $m_3$ := $m_2$($m_1)$ & join of $m_1$ and $m_2$
309 $m_3$ := $m_2$ \ai[\tt]{after} $m_1$ & join of $m_1$ and $m_2$
311 $f_3$ := $f_1$ \ai[\tt]{.} $f_2$ & join of $f_1$ and $f_2$, combining
312 the lists of quasipolynomials over shared domains
314 $q_2$ := $m$ \ai[\tt]{.} $q_1$ & join of $m$ and $q_1$, taking the sum
315 over all elements in the intersection of the range of $m$ and the domain
316 of $q_1$
318 $q_2$ := $m$ \ai[\tt]{before} $q_1$ & $q_2$ := $m$ \ai[\tt]{.} $q_1$
320 $q_2$ := $q_1(m)$ & $q_2$ := $m$ \ai[\tt]{.} $q_1$
322 $q_2$ := $q_1$ \ai[\tt]{after} $m$ & $q_2$ := $m$ \ai[\tt]{.} $q_1$
324 $f_2$ := $m$ \ai[\tt]{.} $f_1$ & join of $m$ and $f_1$, computing a bound
325 over all elements in the intersection of the range of $m$ and the domain
326 of $f_1$
328 $f_2$ := $m$ \ai[\tt]{before} $f_1$ & $f_2$ := $m$ \ai[\tt]{.} $f_1$
330 $f_2$ := $f_1(m)$ & $f_2$ := $m$ \ai[\tt]{.} $f_1$
332 $f_2$ := $f_1$ \ai[\tt]{after} $m$ & $f_2$ := $m$ \ai[\tt]{.} $f_1$
334 $m$ := $s_1$ \ai[\tt]{->} $s_2$ & universal map with domain $s_1$
335 and range $s_2$
337 $q_2$ := $q_1$ \ai{@} $s$ &
338 evaluate the piecewise quasipolynomial $q_1$ in each element
339 of the set $s$ and return a piecewise quasipolynomial
340 mapping each of the individual elements to the resulting
341 constant
343 $q$ := $f$ \ai{@} $s$ &
344 evaluate the piecewise quasipolynomial fold $f$ in each element
345 of the set $s$ and return a piecewise quasipolynomial
346 mapping each of the individual elements to the resulting
347 constant
349 $s_3$ := $s_1$ \ai[\tt]{\%} $s_2$ &
350 simplify $s_1$ in the context of $s_2$, i.e., compute
351 the gist of $s_1$ given $s_2$
353 $m_3$ := $m_1$ \ai[\tt]{\%} $m_2$ &
354 simplify $m_1$ in the context of $m_2$, i.e., compute
355 the gist of $m_1$ given $m_2$
357 $q_2$ := $q_1$ \ai[\tt]{\%} $s$ &
358 simplify $q_1$ in the context of the domain $s$, i.e., compute
359 the gist of $q_1$ given $s$
361 $f_2$ := $f_1$ \ai[\tt]{\%} $s$ &
362 simplify $f_1$ in the context of the domain $s$, i.e., compute
363 the gist of $f_1$ given $s$
365 $m_2$ := $m_1$\ai[\tt]{\^{}-1} & inverse of $m_1$
367 $l$ := $m$\ai[\tt]{\^{}+} &
368 compute an overapproximation of the transitive closure
369 of $m$ and return a list containing the overapproximation
370 and a boolean that is true if the overapproximation
371 is known to be exact
373 $o$ := $l$[$i$] &
374 the element at position $i$ in the list $l$
376 $b$ := $s_1$ \ai[\tt]{=} $s_2$ & is $s_1$ equal to $s_2$?
378 $b$ := $m_1$ \ai[\tt]{=} $m_2$ & is $m_1$ equal to $m_2$?
380 $b$ := $s_1$ \ai[\tt]{<=} $s_2$ & is $s_1$ a subset of $s_2$?
382 $b$ := $m_1$ \ai[\tt]{<=} $m_2$ & is $m_1$ a subset of $m_2$?
384 $b$ := $s_1$ \ai[\tt]{<} $s_2$ & is $s_1$ a proper subset of $s_2$?
386 $b$ := $m_1$ \ai[\tt]{<} $m_2$ & is $m_1$ a proper subset of $m_2$?
388 $b$ := $s_1$ \ai[\tt]{>=} $s_2$ & is $s_1$ a superset of $s_2$?
390 $b$ := $m_1$ \ai[\tt]{>=} $m_2$ & is $m_1$ a superset of $m_2$?
392 $b$ := $s_1$ \ai[\tt]{>} $s_2$ & is $s_1$ a proper superset of $s_2$?
394 $b$ := $m_1$ \ai[\tt]{>} $m_2$ & is $m_1$ a proper superset of $m_2$?
396 $m$ := $s_1$ \ai[\tt]{<<} $s_2$ & a map from
397 $s_1$ to $s_2$ of those elements that live in the same space and
398 such that the elements of $s_1$ are lexicographically strictly smaller
399 than those of $s_2$.
401 $m_3$ := $m_1$ \ai[\tt]{<<} $m_2$ & a map from the domain of
402 $m_1$ to the domain of $m_2$ of those elements such that their images
403 live in the same space and such that the images of the elements of
404 $m_1$ are lexicographically strictly smaller than those of $m_2$.
406 $m$ := $s_1$ \ai[\tt]{<<=} $s_2$ & a map from
407 $s_1$ to $s_2$ of those elements that live in the same space and
408 such that the elements of $s_1$ are lexicographically smaller
409 than those of $s_2$.
411 $m_3$ := $m_1$ \ai[\tt]{<<=} $m_2$ & a map from the domain of
412 $m_1$ to the domain of $m_2$ of those elements such that their images
413 live in the same space and such that the images of the elements of
414 $m_1$ are lexicographically smaller than those of $m_2$.
416 $m$ := $s_1$ \ai[\tt]{>>} $s_2$ & a map from
417 $s_1$ to $s_2$ of those elements that live in the same space and
418 such that the elements of $s_1$ are lexicographically strictly greater
419 than those of $s_2$.
421 $m_3$ := $m_1$ \ai[\tt]{>>} $m_2$ & a map from the domain of
422 $m_1$ to the domain of $m_2$ of those elements such that their images
423 live in the same space and such that the images of the elements of
424 $m_1$ are lexicographically strictly greater than those of $m_2$.
426 $m$ := $s_1$ \ai[\tt]{>>=} $s_2$ & a map from
427 $s_1$ to $s_2$ of those elements that live in the same space and
428 such that the elements of $s_1$ are lexicographically greater
429 than those of $s_2$.
431 $m_3$ := $m_1$ \ai[\tt]{>>=} $m_2$ & a map from the domain of
432 $m_1$ to the domain of $m_2$ of those elements such that their images
433 live in the same space and such that the images of the elements of
434 $m_1$ are lexicographically greater than those of $m_2$.
436 \end{supertabular}