iscc: add dependence analysis operations
[barvinok.git] / doc / isl.tex
blob6798492b0c10b14fe0f7dcda3fa33ec06781c4df
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 $s_2$ := \ai[\tt]{lexmin} $s_1$ &
188 lexicographically minimal element of $s_1$
190 $m_2$ := \ai[\tt]{lexmin} $m_1$ &
191 lexicographically minimal image element
193 $s_2$ := \ai[\tt]{lexmax} $s_1$ &
194 lexicographically maximal element of $s_1$
196 $m_2$ := \ai[\tt]{lexmax} $m_1$ &
197 lexicographically maximal image element
199 $o$ := \ai[\tt]{read} {\tt "}{\it filename}{\tt"} &
200 read object from file
202 $s_2$ := \ai[\tt]{sample} $s_1$ &
203 a sample element of the set $s_1$
205 $m_2$ := \ai[\tt]{sample} $m_1$ &
206 a sample element of the map $m_1$
208 \ai[\tt]{source} {\tt "}{\it filename}{\tt"} &
209 read commands from file
211 $q_2$ := \ai[\tt]{sum} $q_1$ &
212 sum $q_1$ over all integer points in the domain of $q_1$,
213 or, if the domain of $q_1$ wraps a map, over all integer
214 points in the range of the wrapped map.
216 $l$ := \ai[\tt]{ub} $q$ &
217 compute an
218 upper bound on the piecewise quasipolynomial $q$ over
219 all integer points in the domain of $q$
220 and return a list containing the upper bound
221 and a boolean that is true if the upper bound
222 is known to be tight.
223 If the domain of $q$ wraps a map, then the upper
224 bound is computed over all integer points in
225 the range of the wrapped map instead.
227 $l$ := \ai[\tt]{vertices} $s$ &
228 a list of vertices of the rational polytope defined by the same constraints
229 as $s$
231 $s$ := \ai[\tt]{wrap} $m$ &
232 wrap the map in a set
234 $m$ := \ai[\tt]{unwrap} $s$ &
235 unwrap the map from the set
237 $m_4$ := \ai[\tt]{any} $m_1$ \ai[\tt]{before} $m_2$ \ai[\tt]{under} $m_3$ &
238 compute a map from any element $x$ in the domain of $m_1$
239 to any element $y$ in the domain of $m_2$
240 such that their images $m_1(x)$ and $m_2(y)$ overlap
241 and such that $m_3(x) \llt m_3(y)$.
243 $l$ := \ai[\tt]{last} $m_1$ \ai[\tt]{before} $m_2$ \ai[\tt]{under} $m_3$ &
244 compute a map that contains for any element $y$ in the domain of $m_2$
245 a mapping from the lexicographically last element $x$ in the domain of $m_1$
246 (according to the schedule $m_3$) to $y$
247 such that $m_1(x)$ and $m_2(y)$ overlap and such that $m_3(x) \llt m_3(y)$.
248 Return a list containing this map and the set of elements in the domain of
249 $m_2$ for which there is no corresponding element in the domain of $m_1$.
251 $m_5$ := \ai[\tt]{any} $m_1$ \ai[\tt]{last} $m_2$ \ai[\tt]{before} $m_3$
252 \ai[\tt]{under} $m_4$ &
253 compute a map that contains for any element $y$ in the domain of $m_3$
254 a mapping from the lexicographically last element $x$ in the domain of $m_2$
255 (according to the schedule $m_4$) to $y$
256 such that $m_2(x)$ and $m_3(y)$ overlap and such that $m_4(x) \llt m_4(y)$
257 as well as from any element $z$ in the domain of $m_1$ such that
258 $m_1(z)$ and $m_3(y)$ overlap, $m_4(z) \llt m_4(y)$ and such that there
259 is no $x$ in the domain of $m_2$ with
260 $m_2(x) \cap m_3(y) \ne \emptyset$ and $m_4(z) \llt m_4(x) \llt m_4(y)$.
262 $s_3$ := $s_1$ \ai{$+$} $s_2$ & union
264 $m_3$ := $m_1$ \ai{$+$} $m_2$ & union
266 $q_3$ := $q_1$ \ai{$+$} $q_2$ & sum
268 $f_2$ := $f_1$ \ai{$+$} $q$ & sum
270 $f_2$ := $q$ \ai{$+$} $f_1$ & sum
272 $S_3$ := $S_1$ \ai{$+$} $S_2$ & concatenation
274 $S_2$ := $o$ \ai{$+$} $S_1$ &
275 concatenation of stringification of $o$ and $S_1$
277 $S_2$ := $S_1$ \ai{$+$} $o$ &
278 concatenation of $S_1$ and stringification of $o$
280 $s_3$ := $s_1$ \ai{$-$} $s_2$ & set difference
282 $m_3$ := $m_1$ \ai{$-$} $m_2$ & set difference
284 $q_3$ := $q_1$ \ai{$-$} $q_2$ & difference
286 $s_3$ := $s_1$ \ai{$*$} $s_2$ & intersection
288 $m_3$ := $m_1$ \ai{$*$} $m_2$ & intersection
290 $q_3$ := $q_1$ \ai{$*$} $q_2$ & product
292 $m_2$ := $m_1$ \ai{$*$} $s$ & intersect domain of $m_1$ with $s$
294 $q_2$ := $q_1$ \ai{$*$} $s$ & intersect domain of $q_1$ with $s$
296 $f_2$ := $f_1$ \ai{$*$} $s$ & intersect domain of $f_1$ with $s$
298 $s_2$ := $m$($s_1$) & apply map $m$ to set $s_1$
300 $m_3$ := $m_1$ \ai[\tt]{.} $m_2$ & join of $m_1$ and $m_2$
302 $m_3$ := $m_2$($m_1)$ & join of $m_1$ and $m_2$
304 $f_3$ := $f_1$ \ai[\tt]{.} $f_2$ & join of $f_1$ and $f_2$, combining
305 the lists of quasipolynomials over shared domains
307 $q_2$ := $m$ \ai[\tt]{.} $q_1$ & join of $m$ and $q_1$, taking the sum
308 over all elements in the intersection of the range of $m$ and the domain
309 of $q_1$
311 $f_2$ := $m$ \ai[\tt]{.} $f_1$ & join of $m$ and $f_1$, computing a bound
312 over all elements in the intersection of the range of $m$ and the domain
313 of $f_1$
315 $m$ := $s_1$ \ai[\tt]{->} $s_2$ & universal map with domain $s_1$
316 and range $s_2$
318 $q_2$ := $q_1$ \ai{@} $s$ &
319 evaluate the piecewise quasipolynomial $q_1$ in each element
320 of the set $s$ and return a piecewise quasipolynomial
321 mapping each of the individual elements to the resulting
322 constant
324 $q$ := $f$ \ai{@} $s$ &
325 evaluate the piecewise quasipolynomial fold $f$ in each element
326 of the set $s$ and return a piecewise quasipolynomial
327 mapping each of the individual elements to the resulting
328 constant
330 $s_3$ := $s_1$ \ai[\tt]{\%} $s_2$ &
331 simplify $s_1$ in the context of $s_2$, i.e., compute
332 the gist of $s_1$ given $s_2$
334 $m_3$ := $m_1$ \ai[\tt]{\%} $m_2$ &
335 simplify $m_1$ in the context of $m_2$, i.e., compute
336 the gist of $m_1$ given $m_2$
338 $q_2$ := $q_1$ \ai[\tt]{\%} $s$ &
339 simplify $q_1$ in the context of the domain $s$, i.e., compute
340 the gist of $q_1$ given $s$
342 $f_2$ := $f_1$ \ai[\tt]{\%} $s$ &
343 simplify $f_1$ in the context of the domain $s$, i.e., compute
344 the gist of $f_1$ given $s$
346 $m_2$ := $m_1$\ai[\tt]{\^{}-1} & inverse of $m_1$
348 $l$ := $m$\ai[\tt]{\^{}+} &
349 compute an overapproximation of the transitive closure
350 of $m$ and return a list containing the overapproximation
351 and a boolean that is true if the overapproximation
352 is known to be exact
354 $o$ := $l$[$i$] &
355 the element at position $i$ in the list $l$
357 $b$ := $s_1$ \ai[\tt]{=} $s_2$ & is $s_1$ equal to $s_2$?
359 $b$ := $m_1$ \ai[\tt]{=} $m_2$ & is $m_1$ equal to $m_2$?
361 $b$ := $s_1$ \ai[\tt]{<=} $s_2$ & is $s_1$ a subset of $s_2$?
363 $b$ := $m_1$ \ai[\tt]{<=} $m_2$ & is $m_1$ a subset of $m_2$?
365 $b$ := $s_1$ \ai[\tt]{<} $s_2$ & is $s_1$ a proper subset of $s_2$?
367 $b$ := $m_1$ \ai[\tt]{<} $m_2$ & is $m_1$ a proper subset of $m_2$?
369 $b$ := $s_1$ \ai[\tt]{>=} $s_2$ & is $s_1$ a superset of $s_2$?
371 $b$ := $m_1$ \ai[\tt]{>=} $m_2$ & is $m_1$ a superset of $m_2$?
373 $b$ := $s_1$ \ai[\tt]{>} $s_2$ & is $s_1$ a proper superset of $s_2$?
375 $b$ := $m_1$ \ai[\tt]{>} $m_2$ & is $m_1$ a proper superset of $m_2$?
377 $m$ := $s_1$ \ai[\tt]{<<} $s_2$ & a map from
378 $s_1$ to $s_2$ of those elements that live in the same space and
379 such that the elements of $s_1$ are lexicographically strictly smaller
380 than those of $s_2$.
382 $m_3$ := $m_1$ \ai[\tt]{<<} $m_2$ & a map from the domain of
383 $m_1$ to the domain of $m_2$ of those elements such that their images
384 live in the same space and such that the images of the elements of
385 $m_1$ are lexicographically strictly smaller than those of $m_2$.
387 $m$ := $s_1$ \ai[\tt]{<<=} $s_2$ & a map from
388 $s_1$ to $s_2$ of those elements that live in the same space and
389 such that the elements of $s_1$ are lexicographically smaller
390 than those of $s_2$.
392 $m_3$ := $m_1$ \ai[\tt]{<<=} $m_2$ & a map from the domain of
393 $m_1$ to the domain of $m_2$ of those elements such that their images
394 live in the same space and such that the images of the elements of
395 $m_1$ are lexicographically smaller than those of $m_2$.
397 $m$ := $s_1$ \ai[\tt]{>>} $s_2$ & a map from
398 $s_1$ to $s_2$ of those elements that live in the same space and
399 such that the elements of $s_1$ are lexicographically strictly greater
400 than those of $s_2$.
402 $m_3$ := $m_1$ \ai[\tt]{>>} $m_2$ & a map from the domain of
403 $m_1$ to the domain of $m_2$ of those elements such that their images
404 live in the same space and such that the images of the elements of
405 $m_1$ are lexicographically strictly greater than those of $m_2$.
407 $m$ := $s_1$ \ai[\tt]{>>=} $s_2$ & a map from
408 $s_1$ to $s_2$ of those elements that live in the same space and
409 such that the elements of $s_1$ are lexicographically greater
410 than those of $s_2$.
412 $m_3$ := $m_1$ \ai[\tt]{>>=} $m_2$ & a map from the domain of
413 $m_1$ to the domain of $m_2$ of those elements such that their images
414 live in the same space and such that the images of the elements of
415 $m_1$ are lexicographically greater than those of $m_2$.
417 \end{supertabular}