Debian Codegraph @

texmf-dist/doc/latex/gene-logic/gn-logic.tex

raw
1 %*****************************************************************************/
2 %* */
3 %* Version: 1.5 Date: 22/05/2026 File: gn-logic.tex */
4 %* Last Version: File: */
5 %* Changes: */
6 %* 30/12/90 First version of documentation. */
7 %* 21/04/92 new properties */
8 %* 22/05/26 updated */
9 %* */
10 %* Title: */
11 %* Author: Gerd Neugebauer */
12 %* */
13 %* Usage: latex gn-logic.tex */
14 %* */
15 %*****************************************************************************/
16
17 \documentclass[11pt,a4paper]{article}
18 \usepackage{gn-logic}
19
20 \setlength{\unitlength}{1pt}
21
22
23 \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24
25 \newlength{\Width} \Width=\textwidth \advance\Width by -1.5em \divide\Width by 2
26
27 \section{The {\tt gn-logic} style option}
28 Description of Version 1.5 (5/2026) by Gerd Neugebauer \bigskip
29
30 The {\tt gn-logic} style option provides a facility to typeset logical
31 formulas of a certain kind. This style option provides an environment like
32 \verb|eqnarray|, an extended {\tt newtheorem} environment and several macros.
33
34
35
36 \subsection{Mathematical Symbols}
37
38 The following macros provide better usage of the junctors and quantifiers.
39 Especially the spacing is improved.
40
41
42 \noindent\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{4}{l}}
43 \multicolumn{1}{c}{\small Symbol}
44 & \multicolumn{1}{c}{\small Macro}
45 & \multicolumn{2}{c}{\small Example} \\
46 & & & \\
47 $\AND$ & \verb|\AND| & \verb$A\AND B$ & $A\AND B$ \\
48 $\OR$ & \verb|\OR| & \verb$A\OR B$ & $A\OR B$ \\
49 $\XOR$ & \verb|\XOR| & \verb$A\XOR B$ & $A\XOR B$ \\
50 $\IMPLIES$ & \verb|\IMPLIES| & \verb$A\IMPLIES B$ & $A\IMPLIES B$ \\
51 $\IMPL$ & \verb|\IMPL| & \verb$A\IMPL B$ & $A\IMPL B$ \\
52 $\IF$ & \verb|\IF| & \verb$A\IF B$ & $A\IF B$ \\
53 $\IFF$ & \verb|\IFF| & \verb$A\IFF B$ & $A\IFF B$ \\
54 $\IFFdef$ & \verb|\IFFdef| & \verb$A\IFFdef B$ & $A\IFFdef B$ \\
55 $\ANDdots$ & \verb|\ANDdots| & \verb$A_1\ANDdots A_n$ & $A_1\ANDdots A_n$ \\
56 $\ORdots$ & \verb|\ORdots| & \verb$A_1\ORdots A_n$ & $A_1\ORdots A_n$ \\
57 $\is$ & \verb|\is| & \verb$x\is y$ & $x\is y$ \\
58 $\Nat$ & \verb|\Nat| & \verb$n\in\Nat$ & $n\in\Nat$ \\
59 $\Forall$ & \verb|\Forall| & \verb$\Forall x P(x)$ & $\Forall x P(x)$ \\
60 $\Exists$ & \verb|\Exists| & \verb$\Exists y P(x)$ & $\Exists y P(x)$ \\
61 \end{tabular*}
62
63
64 \newcommand{\bs}{{\tt\char"5C}}
65 \newcommand{\mac}[1]{The {\tt\char92 #1} Macro}
66 \newcommand{\macs}[2]{The {\tt\char92 #1} and the {\tt\char92 #2} Macros}
67 \newenvironment{compare}%
68 {\noindent\begin{center}%
69 \begin{tabular}{@{}l@{\hspace*{1.5em}produces\hspace*{1.5em}}l@{}}}%
70 {\end{tabular}\end{center}}
71
72 \subsubsection*{\mac{AND}}
73 This macro can be used for the logical conjunction. In addition to the
74 \verb|\wedge| macro it adds more space and the formulas tend to be better
75 readable. Compare
76
77 \begin{compare}
78 \verb$x=1\AND y=x$ & $x=1\AND y=x$ \\
79 \verb$x=1\wedge y=x$ & $x=1\wedge y=x$ \\
80 \verb$x=1\land y=x$ & $x=1\land y=x$
81 \end{compare}
82
83 \subsubsection*{\mac{OR}}
84 This macro can be used for the logical disjunction. In addition to the
85 \verb|\vee| macro it adds more space. Compare
86
87 \begin{compare}
88 \verb$x=1\OR y=x$ & $x=1\OR y=x$ \\
89 \verb$x=1\vee y=x$ & $x=1\vee y=x$ \\
90 \verb$x=1\lor y=x$ & $x=1\lor y=x$
91 \end{compare}
92
93
94 \subsubsection*{\mac{XOR}}
95 This macro can be used for the exclusive disjunction. It has no common
96 counterpart. The spacing is like in all junctor macros.
97
98 \begin{compare}
99 \verb$x=1\XOR y=x$ & $x=1\XOR y=x$
100 \end{compare}
101
102
103 \subsubsection*{\macs{IMPL}{IMPLIES}}
104 These macros can be used for the logical implication. In addition to the
105 \verb|\rightarrow| macro it adds more space. Compare
106
107 \begin{compare}
108 \verb$x=1\IMPL y=x$ & $x=1\IMPL y=x$ \\
109 \verb$x=1\IMPLIES y=x$ & $x=1\IMPLIES y=x$ \\
110 \verb$x=1\rightarrow y=x$ & $x=1\rightarrow y=x$
111 \end{compare}
112
113
114 \subsubsection*{\mac{IF}}
115 This macro can be used for the logical implication written in reverse order.
116 In addition to the \verb|\leftarrow| macro it adds more space. Compare
117
118 \begin{compare}
119 \verb$x=1\IF y=x$ & $x=1\IF y=x$ \\
120 \verb$x=1\leftarrow y=x$ & $x=1\leftarrow y=x$
121 \end{compare}
122
123 \subsubsection*{\mac{IFF}}
124 This macro can be used for the logical equivalence.
125 In addition to the \verb|\leftrightarrow| macro it adds more space. Compare
126
127 \begin{compare}
128 \verb$x=1\IFF y=x$ & $x=1\IFF y=x$ \\
129 \verb$x=1\leftrightarrow y=x$ & $x=1\leftrightarrow y=x$
130 \end{compare}
131
132 \subsubsection*{\mac{IFFdef}}
133 Like above but with a small ``def'' above the arrow.
134
135 \begin{compare}
136 \verb$x=1\IFFdef y=x$ & $x=1\IFFdef y=x$
137 \end{compare}
138
139 \subsubsection*{\mac{is}}
140 This macro is for typesetting unifiers. In this case the predefined
141 \verb|\setminus| produces too much space.
142
143 \begin{compare}
144 \verb$\{y\setminus x, z\setminus 4\}$ & $\{y\setminus x, z\setminus 4\}$ \\
145 \verb$\{y\is x, z\is 4\}$ & $\{y\is x, z\is 4\}$ \\
146 \verb$\{y\backslash x, z\backslash 4\}$ & $\{y\backslash x, z\backslash 4\}$
147 \end{compare}
148
149 \ifx\AmSTeX\undefined
150 \def\AmSTeX{$\cal A$\kern-.1667em\lower.5ex\hbox
151 {$\cal M$}\kern-.125em$\cal S$-\kern-.1em\TeX}
152 \fi
153
154 \subsubsection*{The Number Macros}
155 These are macros for those who have no access to the \AmSTeX{}
156 fonts. It makes the symbols for the natural numbers, integers,
157 rationals, reals and complex numbers. The usual magnification commands
158 apply to it as well.
159
160
161 \def\BB#1{\csname bb#1\endcsname}
162 \def\Line#1{\LINE{#1}\(\BB{#1}_{\BB{#1}}\)}
163 \def\LINE#1{{\tt \char92bb#1}&%
164 {\tiny\BB{#1}}&%
165 {\scriptsize\BB{#1}}&%
166 {\footnotesize\BB{#1}}&%
167 {\small\BB{#1}}&%
168 {\normalsize\BB{#1}}&%
169 {\large\BB{#1}}&%
170 {\Large\BB{#1}}&%
171 {\LARGE\BB{#1}}&%
172 {\huge\BB{#1}}&%
173 {\Huge\BB{#1}}&%
174 }
175 \begin{center}
176 \begin{tabular}{c|cccccccccc|c}
177 &\multicolumn{10}{|c|}{{\tt \char92tiny \hfill...\hfill\char92normalsize \hfill...\hfill\char92Huge}}&\verb|X_X|
178 \\\hline
179 \Line B\\
180 \verb|\Complex|\Line C\\
181 \Line D\\
182 \Line E\\
183 \Line F\\
184 \Line G\\
185 \Line H\\
186 \Line I\\
187 \Line J\\
188 \Line K\\
189 \Line L\\
190 \Line M\\
191 \verb|\Nat| \Line N\\
192 \Line O\\
193 \Line P\\
194 \verb|\Rat| \Line Q\\
195 \verb|\Real| \Line R\\
196 \verb|\Int| \Line Z\\
197 \Line{One}
198 \end{tabular}
199 \end{center}
200
201 Unfortunately the macros \verb|\bbC|, \verb|\bbG|, \verb|\bbO|, and
202 \verb|\bbQ| do not scale properly when used in subscripts or superscripts of
203 formulae. The following example shows how the sizing can be achieved manually
204
205 \noindent\begin{compare}
206 \verb$\bbQ_{\mbox{\scriptsize \bbQ}}$ & $\bbQ_{\mbox{\scriptsize \bbQ}}$
207 \end{compare}
208
209
210
211 \subsubsection*{\macs{Forall}{Exists}}
212
213 The general problem with quantifiers is that after the quantified variable the
214 following formula is not automatically separated with a small space. This can
215 be overcome by the following macros.
216
217 The \verb|\Forall| and the \verb|\Exists| macros take one argument. They
218 typeset the respective quantifier followed by the argument (i.e.\ the variable)
219 and finally a small space. As usual the argument has to be enclosed in braces
220 if it consists of more than one character. Otherwise the braces can be omitted.
221 This allows an elegant notation of short quantified formulas.
222
223 \noindent\begin{compare}
224 \verb$\Forall x P(x)$ & $\Forall x P(x)$\\
225 \verb$\Forall{x_1,\ldots,x_n}P(x_1,\ldots,x_n)$%
226 &$\Forall{x_1,\ldots,x_n}P(x_1,\ldots,x_n)$\\
227 \verb$\Exists x P(x)$ & $\Exists x P(x)$\\
228 \verb$\Exists{x_1,\ldots,x_n}P(x_1,\ldots,x_n)$%
229 & $\Exists{x_1,\ldots,x_n}P(x_1,\ldots,x_n)$
230 \end{compare}
231
232
233
234 \subsection{The {\tt Formula} Environment}
235
236 This environment allows to typeset logical formulas. The main problem with the
237 \verb|eqnarray| environment was the numbering. In multiline formulas my
238 intention was to have the number in the middle of the formula. Inside this
239 environment several macros are valid.
240
241 \begin{description}
242 \item[{\tt\bs begin\{Formula\}[{\em label}] \bs end\{Formula\}}] \ \\
243 Start the list of formulas. Optionally a label can be given. This label
244 is used to reference the first formula.
245 \item[{\tt\bs =}] \ \\
246 Start a new line.
247 \item[{\tt\bs >}{\em level}] \ \\
248 Start a new line and indent to the given {\em level}. This indentation
249 is done in quantities of \verb|\FormulaIndent| which can be set with
250 the \verb|\setlength| command. The default value is {\tt 3em}.
251 \item[{\tt\bs Form[{\em label}]}] \ \\
252 Start a new formula. Optionally a {\em label} can be given. This {\em
253 label} can be used to reference to the formula (see \verb|\ref|).
254 \end{description}
255
256 Now let's have a look at some examples. First, we see a single two-line formula.
257 Note that the number at the right side is centered between the two lines.
258 \medskip
259
260 \noindent
261 \begin{minipage}{\Width}
262 \small\begin{verbatim}
263 \begin{Formula}
264 P(X) \IMPL
265 \= Q(X) \IFF R_1(X) \OR R_2(X)
266 \end{Formula}
267 \end{verbatim}
268 \end{minipage}
269 \hfill
270 \begin{minipage}{\Width}
271 \begin{Formula}
272 P(X) \IMPL
273 \= Q(X) \IFF R_1(X) \OR R_2(X)
274 \end{Formula}
275 \end{minipage}\medskip
276
277 Next we will see an example of several formulas. The first formula is split to
278 three lines and the third line is indented to level 1. Remark: \verb|\=| is in
279 reality an abbreviation for \verb|\>0|.
280 \medskip
281
282 \noindent
283 \begin{minipage}{\Width}
284 \small\begin{verbatim}
285 \begin{Formula}[form:1]
286 P(X) \IMPL
287 \= Q(X) \IFF R_1(X)
288 \>1 \OR R_2(X)
289 \Form[form:2]
290 S(X) \IMPL
291 \= \neg Q(X) \IFF R_1(X) \OR R_2(X)
292 \end{Formula}
293 \end{verbatim}
294 \end{minipage}
295 \hfill
296 \begin{minipage}{\Width}
297 \begin{Formula}[form:1]
298 P(X) \IMPL
299 \= Q(X) \IFF R_1(X)
300 \>1 \OR R_2(X)
301 \Form[form:2]
302 S(X) \IMPL
303 \= \neg Q(X) \IFF R_1(X) \OR R_2(X)
304 \end{Formula}
305 \end{minipage}\medskip
306
307
308 \subsection{The {\tt NewTheorem} Environment}
309
310 My experience with the {\tt newtheorem} environment was that I had a
311 certain scheme to use it. First, every theorem got a label. Thus,
312 every {\em theorem} was followed by a {\tt label} command. Optionally
313 a {\em theorem} may have a name. This name is typeset right after the
314 number. The body of the {\em theorem} always started in the next
315 line. This led to the definition of an extended {\tt NewTheorem}
316 environment. The arguments are the same as those of the {\tt
317 newtheorem} environment. But the environment defined by this
318 extended command takes two optional arguments. The first optional
319 argument is a label to be assigned to the {\em theorem}. This argument
320 has to be enclosed in parentheses. The second type of optional
321 argument has to be enclosed in brackets. It is typeset in
322 \verb|\small| after the title text. The third argument is optional and
323 enclosed in \verb|<>|. It is typeset in \verb|\small\bf| and
324 surrounded by parentheses. \medskip
325
326 \noindent\begin{minipage}{\Width}
327 \small\begin{verbatim}
328
329 \NewTheorem{guess}{Conjecture}
330
331 \begin{guess}[Fermat](thm:fermat)
332 There do not exist integers $n>2$,
333 $x$, $y$, and $z$ such that
334 $x^n+y^n=z^n$.
335 \end{guess}
336 \end{verbatim}
337 \end{minipage}
338 \hfill
339 \begin{minipage}{\Width}
340 \NewTheorem{guess}{Conjecture}
341
342 \begin{guess}[Fermat](thm:fermat)
343 There do not exist integers $n>2$,
344 $x$, $y$, and $z$ such that
345 $x^n+y^n=z^n$.
346 \end{guess}
347 \end{minipage}
348 \medskip
349
350 The commands used to typeset some of the optional argument can be customized
351 in the following way. The macros \verb|\TheoremTitle| and \verb|\TheoremName|
352 are used to typeset their argument in \verb|\small| and \verb|\small\bf| and
353 enclosed in parentheses respectively. These macros can be redefined using
354 \verb|\renewcommand| as shown in the following example:
355 \medskip
356
357 \noindent\begin{minipage}{\Width}
358 \footnotesize\begin{verbatim}
359 \NewTheorem{theorem}{Theorem}
360 \renewcommand{\TheoremTitle}[1]{{\sf [#1]}}
361 \renewcommand{\TheoremName}[1]{{\small(#1)}}
362 \begin{theorem}[Fermat]<conjecture>(thm:f2)
363 There do not exist integers ...
364 \end{theorem}
365 \end{verbatim}
366 \end{minipage}
367 \hfill
368 \begin{minipage}{\Width}
369 \NewTheorem{theorem}{Theorem}
370 \renewcommand{\TheoremTitle}[1]{{\sf #1}}
371 \renewcommand{\TheoremName}[1]{{\small(#1)}}
372 \begin{theorem}[Fermat]<conjecture>(thm:f2)
373 There do not exist integers $n>2$,
374 $x$, $y$, and $z$ such that
375 $x^n+y^n=z^n$.
376 \end{theorem}
377 \end{minipage}
378
379 \end{document}
380