Debian Codegraph @

texmf-dist/doc/latex/complexity/complexity.tex

raw
1 % complexity latex package documentation
2 % Copyright 2017, by Chris Bourke <[email protected]>
3 % http://chrisbourke.unl.edu
4 %
5 % Please do not distribute altered versions of this document
6
7 \documentclass{ltxdoc}
8
9 \def\complexityversion{0.81a}
10
11 %\usepackage{amsmath}
12 \usepackage[pdftex,a4paper,colorlinks,pdfpagemode=None]{hyperref}
13 \usepackage{longtable}
14 \usepackage{complexity}
15
16 \setlength{\parindent}{0pt} %
17 \setlength{\parskip}{.25cm} %
18
19 \begin{document}
20
21 \title{User's Guide for \texttt{complexity}: a \LaTeX\ package, Version \complexityversion}
22 \author{Chris Bourke}
23 \date{\today}
24
25 \maketitle
26
27 \tableofcontents
28
29 \section{Introduction}
30
31 \subsection{What is \texttt{complexity}?}
32
33 \texttt{complexity} is a \LaTeX\ package that typesets computational
34 complexity classes such as $\P$ (deterministic polynomial time) and
35 $\NP$ (nondeterministic polynomial time) as well as sets (languages)
36 such as $\SAT$ (satisfiability). In all, over 350 commands are
37 defined for helping you to typeset Computational Complexity
38 constructs.
39
40 \section{Package Options}
41
42 The |complexity| package provides two general options---a
43 \emph{font} option (of which there are three classes) and a
44 \emph{mode} option. The font option specifies what font the
45 complexity classes (as well as functions and languages) are typeset
46 in while the mode option specifies \emph{how many} complexity
47 classes are defined.
48
49 One specifies these options in the usual manner. When you use the
50 package, you can pass it the options you wish; for example, calling
51 the package with
52
53 |\usepackage[bold,full]{complexity}|
54
55 specifies that classes (and languages) should be typeset in bold and
56 that the full list of classes should be defined. Invalid options
57 are ignored and only the last option (of each type) is used if
58 multiple, conflicting options are given. The complete options are
59 described in the next two subsections.
60
61 \subsection{Mode Options}
62
63 The mode options specify to what extent the package declares
64 commands for complexity classes. By default, \emph{every}
65 (supported) class command is defined. Alternatively, you can limit
66 the number of commands the |complexity| package defines (and perhaps
67 limit conflicts with other packages or your own commands) by using
68 the |basic| option. This option defines only the most commonly used
69 complexity classes.
70
71 \begin{description}
72
73 \item[|full|] (\emph{Default}) This option will load \emph{every} complexity class
74 that the package has defined. See Section
75 \ref{sec:CompleteListOfComplexityCommands} for a complete list.
76
77 \item[|basic|] This option will only load the
78 ``standard'' complexity classes so as to minimize the number of
79 commands the package defines (i.e. standard classes like $\P$ and
80 $\NP$ but not less well known classes like $\AWPP$ (Almost wide $\PP$).
81
82 \end{description}
83
84 \subsection{Font Options}
85
86 You can easily change the fonts for complexity classes using
87 a package option. The |complexity| package defines three different
88 font entities: a font for complexity classes (|classfont|), a font
89 for languages (|langfont|), and a font for functions (|funcfont|).
90 By default, all of these fonts are typeset using the |mathsf| font.
91 You can change the font for all of them together or specify a font
92 for each individually. To apply a single font to all three entities,
93 simply pass the font (by itself) as an option. The supported font
94 options are as follows.
95
96 \begin{description}
97
98 \item[|sanserif|] (\emph{Default}) This typesets the classes in a
99 |\mathsf| (sans serif) font.
100
101 \item[|roman|] This option typesets the classes in a |\mathrm| (roman)
102 font.
103
104 \item[|bold|] This option typesets the classes in a |\mathbf|
105 (roman, bold) font.
106
107 \item[|typewriter|] This option typesets the classes in a |\mathtt|
108 (typewriter) font.
109
110 \item[|italic|] This option typesets the classes in a |\mathit|
111 (math italic) font.
112
113 \item[|caps|] This option typesets the classes in a |\textsc|
114 (small caps font) font.
115
116 \item[|slant|] This option typesets the classes in a |\textsl|
117 (slanted font) font.
118
119 \end{description}
120
121 As an alternative, you can specify a different font for each of the
122 three entities. To do this, you simply qualify the font with a
123 key-value pair: either |classfont|, |langfont|, or |funcfont|. For
124 example, if we want our complexity classes to be typeset in |bold|,
125 our languages to be typeset in |roman| and our functions to be
126 typeset in |italic|, we would call the package using:
127
128 \begin{verbatim}
129 \usepackage[classfont=bold,
130 langfont=roman,
131 funcfont=italic]{complexity}
132 \end{verbatim}
133
134 Examples of how each of the fonts appears when typeset can be found
135 in Table \ref{table:Examples}.
136
137 \begin{table}[h]
138 \centering
139 \caption{An Example of each font}\label{table:Examples}
140 \begin{tabular}{lp{3cm}p{4cm}p{3.5cm}}
141 Font & |classfont| & |langfont| & |funcfont| \\
142 \hline %
143 \hline %
144 ~\\
145 |sanserif| & $\mathsf{P} \subseteq \mathsf{NP}$, & $\CVP \leq_m \SAT$, & $\polylog \in O(\poly)$,\\
146 ~ & $\PSPACE \subseteq \EXP$ & $\SAT \leq_T \MaxSAT$ & $\polylog \in \Omega(\llog)$ \\
147 ~\\
148 |roman| & $\mathrm{P} \subseteq \mathrm{NP}$, & $\mathrm{CVP} \leq_m \mathrm{SAT}$, & $\mathrm{polylog} \in O(\mathrm{poly})$,\\
149 ~ & $\mathrm{PSPACE} \subseteq \mathrm{EXP}$ & $\mathrm{SAT} \leq_T \mathrm{MaxSAT}$ & $\mathrm{polylog} \in \Omega(\mathrm{log})$ \\
150 ~\\
151 |bold| & $\mathbf{P} \subseteq \mathbf{NP}$, & $\mathbf{CVP} \leq_m \mathbf{SAT}$, & $\mathbf{polylog} \in O(\mathbf{poly})$,\\
152 ~ & $\mathbf{PSPACE} \subseteq \mathbf{EXP}$ & $\mathbf{SAT} \leq_T \mathbf{MaxSAT}$ & $\mathbf{polylog} \in \Omega(\mathbf{log})$ \\
153 ~\\
154 |typewriter| & $\mathtt{P} \subseteq \mathtt{NP}$, & $\mathtt{CVP} \leq_m \mathtt{SAT}$, & $\mathtt{polylog} \in O(\mathtt{poly})$,\\
155 ~ & $\mathtt{PSPACE} \subseteq \mathtt{EXP}$ & $\mathtt{SAT} \leq_T \mathtt{MaxSAT}$ & $\mathtt{polylog} \in \Omega(\mathtt{log})$ \\
156 ~\\
157 |italic| & $\mathit{P} \subseteq \mathit{NP}$, & $\mathit{CVP} \leq_m \mathit{SAT}$, & $\mathit{polylog} \in O(\mathit{poly})$,\\
158 ~ & $\mathit{PSPACE} \subseteq \mathit{EXP}$ & $\mathit{SAT} \leq_T \mathit{MaxSAT}$ & $\mathit{polylog} \in \Omega(\mathit{log})$ \\
159 ~\\
160 |caps| & $\textsc{P} \subseteq \textsc{NP}$, & $\textsc{CVP} \leq_m \textsc{SAT}$, & $\textsc{polylog} \in O(\textsc{poly})$,\\
161 ~ & $\textsc{PSPACE} \subseteq \textsc{EXP}$ & $\textsc{SAT} \leq_T \textsc{MaxSAT}$ & $\textsc{polylog} \in \Omega(\textsc{log})$ \\
162 ~ & \multicolumn{2}{l}{Better example: $\textsc{promiseRP} \subseteq \textsc{promiseBPP}$}\\
163 ~\\
164 |slant| & $\textsl{P} \subseteq \textsl{NP}$, & $\textsl{CVP} \leq_m \textsl{SAT}$, & $\textsl{polylog} \in O(\textsl{poly})$,\\
165 ~ & $\textsl{PSPACE} \subseteq \textsl{EXP}$ & $\textsl{SAT} \leq_T \textsl{MaxSAT}$ & $\textsl{polylog} \in \Omega(\textsl{log})$ \\
166 ~\\
167 \end{tabular}
168 \end{table}
169
170 \subsubsection{The \texttt{small} Option}
171
172 A special option is the |small| option and pertains only to how
173 complexity classes (|classfont|) are typeset. Since classes are
174 typeset in uppercase letters, they tend to be more dominant. If
175 you frequently typeset classes such as $\PSPACE$ or $\DTIME$ it can
176 interrupt the normal flow of text layouts. One solution to this is
177 to typeset classes 1pt smaller than the surrounding text. This is
178 the approach taken in some texts (most notably, Papadimitriou's book
179 \emph{Computational Complexity}, 1994) and it works quite well.
180 The following samples illustrate the difference. The first sample
181 uses the default font size while the second uses a font that is 1pt
182 smaller (internally, the |\small| command is used). The difference is
183 subtle but when used in a long text, flows more naturally.
184
185 \begin{quote}
186 There are deterministic classes such as $\PSPACE$, nondeterministic
187 classes such as $\NP$, and functional classes such as $\GapP$. But
188 I like them all.
189 \end{quote}
190
191 \begin{quote}
192 There are deterministic classes such as $\hbox{\small\PSPACE}$,
193 nondeterministic classes such as $\hbox{\small \NP}$, and functional
194 classes such as $\hbox{\small \GapP}$. But I like them all.
195 \end{quote}
196
197 To get the same effect using |complexity|, use the |small|
198 option:
199
200 |\usepackage[small]{complexity}|
201
202 with any combination of the other options (it works for all
203 fonts, but some do not look as good as others; |typewriter|
204 for example looks bad with this option). Remember, however
205 that this option only affects how classes are typeset, not
206 languages.
207
208 This option only affects how classes are
209 typeset in the display and in-line mathmodes. It has no effect in
210 a footnote or some special environment. Subscripts,
211 superscripts (as well as subsubscripts and supersuperscripts) are
212 not effected either. \TeX\ is allowed to automatically change font
213 sizes for these cases.
214
215 \subsection{Overridden Commands}
216
217 Three commands in the |complexity| package override built-in \TeX\
218 commands. Specifically, |\L| (which typesets the symbol
219 \defaultL), |\P| (typesetting \defaultP), and |\S| (which typesets the
220 symbol \defaultS) are all redefined for use in the package. The
221 |complexity| package preserves these commands so that you may still
222 use them. To use any of these symbols, use the commands
223 |\defaultL|, |\defaultP|, and |\defaultS| instead.
224
225 In some situations this redefinition is not desirable (if you need
226 these symbols but cannot use the |\default| versions). You can
227 disable the overriding of these three commands using the option
228 |disableredefinitions|; for example:
229
230 |\usepackage[disableredefinitions]{complexity}|
231
232 Three alternatives are defined if you disable the overrides:
233 |\cL|, |\cP| and |\cS| that typeset the classes $\cL$, $\cP$
234 and $\cS$ respectively.
235
236
237 \section{Using the Package}
238
239 Each of the commands is defined using |\ensuremath| so that you
240 need not be in \LaTeX's mathmode to use them. However, if you
241 use a command outside of mathmode, \TeX\ may not properly insert
242 surrounding whitespace. It is recommended to always use |complexity|
243 commands inside mathmode. A complete list of commands for classes
244 can be found in Section \ref{sec:CompleteListOfComplexityCommands}.
245
246 \subsection{Special Commands}
247
248 In addition to complexity classes, the |complexity| package also
249 conveniently defines several commands for commonly used functions
250 and languages. In particular, |\co| (ex: $\co$) and |\parity| (an
251 alias for |\oplus|, typesetting $\oplus$) can be placed preceding a
252 class to refer to the complement or counting versions respectively.
253
254 \subsection{Function Commands}
255
256 |complexity| defines several general classes of functions such as
257 logarithms and polynomials. Table \ref{table:SpecialCommands} gives
258 a complete list of these functions.
259
260 \begin{table}[h]
261 \centering %
262 \caption{\texttt{func} Commands} %
263 \label{table:SpecialCommands}
264 \begin{tabular}{llp{8cm}}
265 Command & Result & Comment \\
266 \hline\hline
267 |\llog| & $\llog$ & Denotes logarithmic functions. The command %
268 is invoked with \emph{two} l's so as to not interfere
269 with the \LaTeX\ |\log| command.\\
270 |\poly| & $\poly$ & Denotes polynomial functions \\
271 |\polylog| & $\polylog$ & Denotes polylogarithmic functions \\
272
273 |\qpoly| & $\qpoly$ & Denotes polynomial functions for quantum advice\\
274 |\qlog| & $\qlog$ & Denotes logarithmic functions for quantum advice \\
275
276 |\MOD| & $\MOD$ & Used for Modular classes/functions \\
277 |\Mod| & $\Mod$ & Used for Modular classes/functions \\
278 \end{tabular}
279 \end{table}
280
281 \subsection{Language Commands}
282
283 |complexity| also defines commands to typeset languages.
284 A complete list of predefined language commands can
285 be found in Table \ref{table:LanguageCommands}. The number of
286 commands is sparse; this was intentional. How one refers to
287 languages is far less standard than how one refers to classes. Some
288 people like to explicitly write \emph{every} word
289 ($\lang{WeightedHamiltonianCycle}$, or $\lang{WEIGHTED~HAMILTONIAN~
290 CYCLE}$), while others have their own abbreviations. Keeping the
291 number of languages |complexity| defines to a minimum allows for the
292 maximum flexibility.
293
294 \begin{table}[h]
295 \centering %
296 \caption{Special \texttt{complexity} Commands} %
297 \label{table:LanguageCommands}
298 \begin{tabular}{llp{7cm}}
299 Command & Result & Comment \\
300 \hline\hline\\
301 |\CVP| & $\CVP$ & Used for the Circuit Value Problem (a $\P$-complete set) \\
302 |\SAT| & $\SAT$ & Used for Satisfiability (an $\NP$-complete set)\\
303 |\MaxSAT| & $\MaxSAT$ & Used for the Lexicographically maximum
304 satisfiability optimization problem (complete for $\OptP$) \\
305 \end{tabular}
306 \end{table}
307
308
309 \newpage
310 \subsection{Complete List of Class Commands}
311 \label{sec:CompleteListOfComplexityCommands}
312
313 A complete list (in alpha-numeric order according to the command
314 name) of complexity commands is given below. The first item in each
315 row is the command itself. The second is an example of how it is
316 typeset using the default |sanserif| font. Finally, the third item
317 indicates which mode the command is defined in.
318
319 \begin{longtable}{lll}
320 %\caption{Complete Table of \texttt{complexity} Commands}
321 %\label{table:CompleteCommands}
322 \input{tableofclasses}
323 \end{longtable}
324
325
326 \section{Customization}
327 \label{sec:Customization}
328
329 The |complexity| package provides some 350 commands to typeset
330 complexity classes. However, that should not mean that the commands
331 here are the \emph{only} ones you'll ever need. Expanding the list
332 of commands to suit your needs is very easy. Please note, however,
333 it is preferred that you not alter the base style file
334 (|complexity.sty|). Instead, a file is provided for you to define
335 your commands in (|mycomplexity.sty|).
336
337 \subsection{Class Commands}
338 To define a new complexity class, you can use the |\newclass|
339 command which is similar (in fact is a macro for) the \LaTeX\
340 command, |\newcommand|. The command takes two arguments: the
341 command that you will use and how the class will be typeset. For
342 example, say that we want to define the new complexity class,
343 ``VCCC'' (``very complex complexity class''). We would use
344
345 |\newclass{\VCCC}{VCCC}|
346
347 Then, anytime we wanted to typeset our new class, we simply use
348 |$\VCCC$|. Internally, |complexity| typesets everything using the
349 command |\ComplexityFont| which is setup at the invocation of the
350 package.
351
352 You also may have different preferences for typesetting the classes
353 that |complexity| already defines. For instance, the class
354 $\promiseBPP$ (typeset using the command |\promiseBPP|) is typeset
355 with ``promise'' explicitly written. Preferring brevity over
356 clarity, you may wish to typeset the same class as
357 ``$\ComplexityFont{pBPP}$''. To do this, we use the |\renewclass|
358 as follows.
359
360 |\renewclass{\promiseBPP}{pBPP}|
361
362 However, this only changes what the command does, not how we invoke
363 it---we would still use |$\promiseBPP$|.
364
365 Consider a more complex example. Say we want to change how the
366 class $\ModkL$ (typeset using the command |\ModkL|) is typeset. By
367 default, the subscript $k$ is typeset in regular mathmode. We can
368 change it so that it is typeset in the same font as the rest of the
369 classes. We will have to specify this using |\renewcommand| as
370 follows.
371
372 \begin{verbatim}
373 \renewcommand{\ModkL}{ %
374 {
375 \ComplexityFont{Mod}_{\ComplexityFont{k}}\ComplexityFont{L}
376 }
377 }
378 \end{verbatim}
379
380 Note the use of ``extra'' brackets. In your commands, more is
381 always better (or at least safer); since we are using subscripts and
382 superscripts, we want to ensure that if we use the |\ModkL| command
383 itself in a subscript or superscript (say as an oracle) are typeset
384 correctly.
385
386 \subsection{Language Commands}
387
388 You can define languages (to be typeset in the |langfont|) in a
389 similar manner. Instead of using |\newclass|, however, you would
390 use the command |\newlang|. You can also use |\lang| as a stand
391 alone command in your document (i.e. |$\lang{Matching} \in \P$|) or
392 you can define a command (using |\lang|) that can be reused
393 throughout your document. Again, we give an example. Say we wanted
394 to typeset the language ``Graph Non-Isomorphism'' using the
395 abbreviation, ``GNI''. We could define something like the following.
396
397 |\newlang{\GNI}{GNI}|
398
399 In our document, we would would use something like |$\GNI \in \AM$|.
400 We can also redefine any predefined language commands using the
401 |\renewlang| command as before.
402
403 \subsection{Function Commands}
404
405 Again, the procedure for typesetting your own functions is the same
406 as for classes. Here, however, you use the |\func| command. You
407 can use it as a stand alone command (|$\func{lin}(n) \in \Theta(n)$|) %
408 or you can define a command that can be reused. Say we wanted to
409 typeset a class of subexponential functions, say ``subexp''. We
410 could define something like the following.
411
412 |\newfunc{\subexp}{subexp}|
413
414 In our document, we could then use |$\subexp(n) = 2^{o(n)}$|. We can
415 redefine a function command using |\renewfunc|.
416
417 \section{Extended Example}
418
419 Here, we present an extended example using the package. Consider
420 the following \TeX\ code.
421
422 \begin{verbatim}
423 \documentclass{article}
424 \usepackage{complexity}
425 \begin{document}
426 It follows immediately from the definitions of $\P$ and $\NP$ that
427 $$\P \subseteq \NP$$
428 but the million dollar question is whether or not $\P
429 \stackrel{?}{=} \NP$. As a generalization to these classes,
430 Stockmeyer (1976) defined a \emph{polynomial} hierarchy using
431 oracles.
432
433 \textbf{Definition}[Stockmeyer 1976] \\
434 Let $\Delta_0\P = \Sigma_0\P = \Pi_0\P = \P$. Then for $i > 0$, let
435 \begin{itemize}
436 \item $\Delta_i\P = \P$ with a $\Sigma_{i-1}\P$ oracle.
437 \item $\Sigma_i\P = \NP$ with $\Sigma_{i-1}\P$ oracle.
438 \item $\Pi_i\P = \coNP$ with $\Sigma_{i-1}\P$ oracle.
439 \end{itemize}
440 Then $\PH$ is the union of these classes for all nonnegative
441 constant $i$.
442
443 It has been shown that $\PH \subseteq \PSPACE$. Moreover, Toda
444 (1989) showed the following
445 \textbf{Theorem}
446 $$\PH \subseteq \P^\PP$$
447 and since since $\P^\PP = \P^{\#\P}$ it follows that
448 $$\PH \subseteq \P^{\#\P}$$
449
450 \end{document}
451 \end{verbatim}
452
453 \hrule
454
455 Would produce something like the following:
456
457 \hrule
458
459 It follows immediately from the definitions of $\P$ and $\NP$ that
460 $$\P \subseteq \NP$$
461 but the million dollar question is whether or not $\P
462 \stackrel{?}{=} \NP$. As a generalization to these classes,
463 Stockmeyer (1976) defined a \emph{polynomial} hierarchy using
464 oracles.
465
466 \textbf{Definition}[Stockmeyer 1976] \\
467 Let $\Delta_0\P = \Sigma_0\P = \Pi_0\P = \P$. Then for $i > 0$, let
468 \begin{itemize}
469 \item $\Delta_i\P = \P$ with a $\Sigma_{i-1}\P$ oracle.
470 \item $\Sigma_i\P = \NP$ with $\Sigma_{i-1}\P$ oracle.
471 \item $\Pi_i\P = \coNP$ with $\Sigma_{i-1}\P$ oracle.
472 \end{itemize}
473 Then $\PH$ is the union of these classes for all nonnegative
474 constant $i$.
475
476 It has been shown that $\PH \subseteq \PSPACE$. Moreover, Toda
477 (1989) showed the following.
478
479 \textbf{Theorem}
480 $$\PH \subseteq \P^\PP$$
481 and since since $\P^\PP = \P^{\#\P}$ it follows that
482 $$\PH \subseteq \P^{\#\P}$$
483
484 \hrule
485
486 \subsection{Acknowledgements}
487
488 I'd like to thank Till Tantau for several useful suggestions and
489 feature requests as well as some clever code segments for the
490 |small| option. I'd also like to thank Enrico Gregorio for the
491 suggested fix to disable redefinitions.
492
493 \end{document}