add isl_union_pw_qpolynomial_sum
[barvinok.git] / doc / isl.tex
blob2e1c187c829d7d14ca26bbf5d0b9983b112e72c9
1 \section{\protect\isl/ interface}
3 \subsection{Library}
5 The \barvinok/ library currently supports only a few
6 functions that interface with the \isl/ library.
7 In time, this interface will grow and is set to replace
8 the \PolyLib/ interface.
9 For more information on the \isl/ data structures, see
10 the \isl/ user manual.
12 \begin{verbatim}
13 __isl_give isl_pw_qpolynomial *isl_set_card(__isl_take isl_set *set);
14 __isl_give isl_union_pw_qpolynomial *isl_union_set_card(
15 __isl_take isl_union_set *uset);
16 \end{verbatim}
17 Compute the number of elements in an \ai[\tt]{isl\_set}
18 or \ai[\tt]{isl\_union\_set}.
19 The resulting \ai[\tt]{isl\_pw\_qpolynomial}
20 or \ai[\tt]{isl\_union\_pw\_qpolynomial} has purely parametric cells.
22 \begin{verbatim}
23 __isl_give isl_pw_qpolynomial *isl_map_card(__isl_take isl_map *map);
24 __isl_give isl_union_pw_qpolynomial *isl_union_map_card(
25 __isl_take isl_union_map *umap);
26 \end{verbatim}
27 Compute a closed form expression for the number of image elements
28 associated to any element in the domain of the given \ai[\tt]{isl\_map}
29 or \ai[\tt]{isl\_union\_map}.
30 The union of the cells in the resulting \ai[\tt]{isl\_pw\_qpolynomial}
31 is equal to the domain of the input \ai[\tt]{isl\_map}.
33 \begin{verbatim}
34 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sum(
35 __isl_take isl_pw_qpolynomial *pwqp);
36 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sum(
37 __isl_take isl_union_pw_qpolynomial *upwqp);
38 \end{verbatim}
39 Compute the sum of the given piecewise quasipolynomial over
40 all integer points in the domain. The result is a piecewise
41 quasipolynomial that only involves the parameters.
43 \subsection{Calculator}
45 The \ai[\tt]{iscc} calculator offers an interface to some
46 of the functionality provided by the \isl/ and \barvinok/
47 libraries.
48 The supported operations are shown in \autoref{t:iscc}.
49 Here are some examples:
50 \begin{verbatim}
51 P := [n, m] -> { [i,j] : 0 <= i <= n and i <= j <= m };
52 card P;
54 f := [n,m] -> { [i,j] -> i*j + n*i*i*j : i,j >= 0 and 5i + 27j <= n+m };
55 sum f;
56 s := sum f;
57 s @ [n,m] -> { [] : 0 <= n,m <= 20 };
59 f := [n] -> { [i] -> 2*n*i - n*n + 3*n - 1/2*i*i - 3/2*i-1 :
60 (exists j : 0 <= i < 4*n-1 and 0 <= j < n and
61 2*n-1 <= i+j <= 4*n-2 and i <= 2*n-1 ) };
62 ub f;
63 u := (ub f)[0];
64 u @ [n] -> { [] : 0 <= n <= 10 };
66 m := [n] -> { [i,j] -> [i+1,j+1] : 1 <= i,j < n;
67 [i,j] -> [i+1,j-1] : 1 <= i < n and 2 <= j <= n };
68 m^+;
69 (m^+)[0];
70 \end{verbatim}
72 \bottomcaption{{\tt iscc} operations. The variables
73 have the following types,
74 $s$: set,
75 $m$: map,
76 $q$: piecewise quasipolynomial,
77 $f$: piecewise quasipolynomial fold,
78 $l$: list,
79 $i$: integer,
80 $b$: boolean,
81 $o$: object of any type
83 \label{t:iscc}
84 \tablehead{
85 Syntax & Meaning
87 \hline
89 \tabletail{
90 \multicolumn{2}{r}{\small\sl continued on next page}
93 \tablelasttail{}
94 \begin{supertabular}{lp{0.7\textwidth}}
95 $s_2$ := \ai[\tt]{aff} $s_1$ & affine hull of $s_1$
97 $m_2$ := \ai[\tt]{aff} $m_1$ & affine hull of $m_1$
99 $q$ := \ai[\tt]{card} $s$ &
100 number of elements in the set $s$
102 $q$ := \ai[\tt]{card} $m$ &
103 number of elements in the image of a domain element
105 $s_2$ := \ai[\tt]{coalesce} $s_1$ &
106 simplify the representation of set $s_1$ by trying
107 to combine pairs of basic sets into a single
108 basic set
110 $m_2$ := \ai[\tt]{coalesce} $m_1$ &
111 simplify the representation of map $m_1$ by trying
112 to combine pairs of basic maps into a single
113 basic map
115 $q_2$ := \ai[\tt]{coalesce} $q_1$ &
116 simplify the representation of $q_1$ by trying
117 to combine pairs of basic sets in the domain
118 of $q_1$ into a single basic set
120 $f_2$ := \ai[\tt]{coalesce} $f_1$ &
121 simplify the representation of $f_1$ by trying
122 to combine pairs of basic sets in the domain
123 of $f_1$ into a single basic set
125 $s_3$ := $s_1$ \ai[\tt]{cross} $s_2$ &
126 Cartesian product of $s_1$ and $s_2$
128 $m_3$ := $m_1$ \ai[\tt]{cross} $m_2$ &
129 Cartesian product of $m_1$ and $m_2$
131 $s$ := \ai[\tt]{deltas} $m$ &
132 the set $\{\, y - x \mid x \to y \in m \,\}$
134 $s$ := \ai[\tt]{dom} $m$ &
135 domain of map $m$
137 $s$ := \ai[\tt]{dom} $q$ &
138 domain of piecewise quasipolynomial $q$
140 $s$ := \ai[\tt]{dom} $f$ &
141 domain of piecewise quasipolynomial fold $f$
143 $s$ := \ai[\tt]{ran} $m$ &
144 range of map $m$
146 $s_2$ := \ai[\tt]{lexmin} $s_1$ &
147 lexicographically minimal element of $s_1$
149 $m_2$ := \ai[\tt]{lexmin} $m_1$ &
150 lexicographically minimal image element
152 $s_2$ := \ai[\tt]{lexmax} $s_1$ &
153 lexicographically maximal element of $s_1$
155 $m_2$ := \ai[\tt]{lexmax} $m_1$ &
156 lexicographically maximal image element
158 $o$ := \ai[\tt]{read} {\tt "}{\it filename}{\tt"} &
159 read object from file
161 $s_2$ := \ai[\tt]{sample} $s_1$ &
162 a sample element of the set $s_1$
164 $m_2$ := \ai[\tt]{sample} $m_1$ &
165 a sample element of the map $m_1$
167 $q_2$ := \ai[\tt]{sum} $q_1$ &
168 sum $q_1$ over all integer points in the domain of $q_1$
170 $l$ := \ai[\tt]{ub} $q$ &
171 compute an
172 upper bound on the piecewise quasipolynomial $q$ over
173 all integer points in the domain of $q$
174 and return a list containing the upper bound
175 and a boolean that is true if the upper bound
176 is known to be tight
178 $l$ := \ai[\tt]{vertices} $s$ &
179 a list of vertices of the rational polytope defined by the same constraints
180 as $s$
182 $s_3$ := $s_1$ \ai{$+$} $s_2$ & union
184 $m_3$ := $m_1$ \ai{$+$} $m_2$ & union
186 $q_3$ := $q_1$ \ai{$+$} $q_2$ & sum
188 $s_3$ := $s_1$ \ai{$-$} $s_2$ & set difference
190 $m_3$ := $m_1$ \ai{$-$} $m_2$ & set difference
192 $q_3$ := $q_1$ \ai{$-$} $q_2$ & difference
194 $s_3$ := $s_1$ \ai{$*$} $s_2$ & intersection
196 $m_3$ := $m_1$ \ai{$*$} $m_2$ & intersection
198 $q_3$ := $q_1$ \ai{$*$} $q_2$ & product
200 $m_2$ := $m_1$ \ai{$*$} $s$ & intersect domain of $m_1$ with $s$
202 $q_2$ := $q_1$ \ai{$*$} $s$ & intersect domain of $q_1$ with $s$
204 $f_2$ := $f_1$ \ai{$*$} $s$ & intersect domain of $f_1$ with $s$
206 $s_2$ := $m$($s_1$) & apply map $m$ to set $s_1$
208 $m_3$ := $m_1$ \ai[\tt]{.} $m_2$ & join of $m_1$ and $m_2$
210 $m_3$ := $m_2$($m_1)$ & join of $m_1$ and $m_2$
212 $m$ := $s_1$ \ai[\tt]{->} $s_2$ & universal map with domain $s_1$
213 and range $s_2$
215 $q_2$ := $q_1$ \ai{@} $s$ &
216 evaluate the piecewise quasipolynomial $q_1$ in each element
217 of the set $s$ and return a piecewise quasipolynomial
218 mapping each of the individual elements to the resulting
219 constant
221 $q$ := $f$ \ai{@} $s$ &
222 evaluate the piecewise quasipolynomial fold $f$ in each element
223 of the set $s$ and return a piecewise quasipolynomial
224 mapping each of the individual elements to the resulting
225 constant
227 $s_3$ := $s_1$ \ai[\tt]{\%} $s_2$ &
228 simplify $s_1$ in the context of $s_2$, i.e., compute
229 the gist of $s_1$ given $s_2$
231 $m_3$ := $m_1$ \ai[\tt]{\%} $m_2$ &
232 simplify $m_1$ in the context of $m_2$, i.e., compute
233 the gist of $m_1$ given $m_2$
235 $q_2$ := $q_1$ \ai[\tt]{\%} $s$ &
236 simplify $q_1$ in the context of the domain $s$, i.e., compute
237 the gist of $q_1$ given $s$
239 $f_2$ := $f_1$ \ai[\tt]{\%} $s$ &
240 simplify $f_1$ in the context of the domain $s$, i.e., compute
241 the gist of $f_1$ given $s$
243 $m_2$ := $m_1$\ai[\tt]{\^{}-1} & inverse of $m_1$
245 $l$ := $m$\ai[\tt]{\^{}+} &
246 compute an overapproximation of the transitive closure
247 of $m$ and return a list containing the overapproximation
248 and a boolean that is true if the overapproximation
249 is known to be exact
251 $o$ := $l$[$i$] &
252 the element at position $i$ in the list $l$
254 $b$ := $s_1$ \ai[\tt]{=} $s_2$ & is $s_1$ equal to $s_2$?
256 $b$ := $m_1$ \ai[\tt]{=} $m_2$ & is $m_1$ equal to $m_2$?
258 $b$ := $s_1$ \ai[\tt]{<=} $s_2$ & is $s_1$ a subset of $s_2$?
260 $b$ := $m_1$ \ai[\tt]{<=} $m_2$ & is $m_1$ a subset of $m_2$?
262 $b$ := $s_1$ \ai[\tt]{<} $s_2$ & is $s_1$ a proper subset of $s_2$?
264 $b$ := $m_1$ \ai[\tt]{<} $m_2$ & is $m_1$ a proper subset of $m_2$?
266 $b$ := $s_1$ \ai[\tt]{>=} $s_2$ & is $s_1$ a superset of $s_2$?
268 $b$ := $m_1$ \ai[\tt]{>=} $m_2$ & is $m_1$ a superset of $m_2$?
270 $b$ := $s_1$ \ai[\tt]{>} $s_2$ & is $s_1$ a proper superset of $s_2$?
272 $b$ := $m_1$ \ai[\tt]{>} $m_2$ & is $m_1$ a proper superset of $m_2$?
274 \end{supertabular}