Debian Codegraph @

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

raw
1 \documentclass[a4paper,1pt]{article}
2
3 \usepackage[T1]{fontenc}
4 \usepackage{booktabs}
5 \usepackage{bookmark}
6 \usepackage{geometry}
7 \usepackage{xcolor}
8 \usepackage{hyperref}
9 \usepackage{tcolorbox}
10 \usepackage{listings}
11 \usepackage{fancyhdr}
12 \usepackage{seqcalc}
13
14 \geometry{margin=3cm}
15
16 \lstset{
17 basicstyle=\ttfamily\small,
18 breaklines=true,
19 columns=fullflexible,
20 }
21
22 \definecolor{seqblue}{HTML}{1A4E8A}
23 \definecolor{seqgray}{HTML}{4A4A4A}
24 \definecolor{seqlight}{HTML}{E9EEF4}
25 \definecolor{seqaccent}{HTML}{C0392B}
26
27 \hypersetup{
28 colorlinks=true,
29 linkcolor=black,
30 urlcolor=seqaccent,
31 citecolor=seqblue,
32 pdftitle={The seqcalc package},
33 pdfauthor={Julian}
34 }
35
36 \pagestyle{fancy}
37 \fancyhead[L]{\texttt{seqcalc} Documentation}
38 \fancyhead[R]{Version \seqcalcVersion}
39
40 \tcbset{
41 seqexample/.style={
42 colback=seqlight,
43 colframe=seqblue,
44 coltitle=white,
45 fonttitle=\bfseries,
46 boxrule=0.8pt,
47 sidebyside
48 }
49 }
50
51 \usepackage{titlesec}
52 \titleformat{\section} {\Large\bfseries\color{seqblue}} {\thesection}{1em}{}
53 \titleformat{\subsection} {\large\bfseries\color{seqblue}} {\thesubsection}{1em}{}
54
55 \makeatletter
56 \renewcommand{\maketitle}{
57 \begin{titlepage}
58 \centering
59 {\Huge\bfseries\color{seqblue} \@title \par}
60 \vspace{0.5cm}
61 {\Large A structured sequent calculus wrapper for \texttt{bussproofs}\par} \vspace{1.5cm}
62 {\large \@author \par} \vspace{0.5cm}
63 {\large Version \seqcalcVersion{} — \@date \par} \vspace{1.5cm}
64
65 \begin{tcolorbox}[ width=0.85\textwidth, colback=seqlight, colframe=seqblue, arc=2pt, boxrule=0.8pt, left=8pt,right=8pt,top=8pt,bottom=8pt, ]
66 \small\centering\begin{abstract}
67 \texttt{seqcalc} is a structured wrapper around the \texttt{bussproofs} package. It provides a declarative interface for sequent calculus proofs, including rule declaration, rule application, formula normalization, shortcuts, and optional standard rule sets. The goal is to simplify the construction of proof trees while keeping the underlying \texttt{bussproofs} layout untouched.
68 \end{abstract}
69 \end{tcolorbox}
70 \vfill
71 {\small Project page: \url{https://github.com/lambdaphoenix/seqcalc}\par}
72 \end{titlepage} }
73 \makeatother
74
75 \title{\textbf{seqcalc}}
76 \author{Julian}
77 \date{\today}
78
79 \begin{document}
80
81 \maketitle
82
83 \tableofcontents
84 \newpage
85
86 \section{Introduction}
87
88 The \texttt{bussproofs} package by Sam Buss provides a flexible system for typesetting proof. The \texttt{seqcalc} package builds on top of it by offering a structured, declarative interface for sequent calculus proofs. Its goal is to simplify the construction of proof trees while preserving the layout and behaviour of \texttt{bussproofs}.
89 \texttt{seqcalc} provides:
90 \begin{itemize}
91 \item a declarative rule system with automatic macro generation,
92 \item optional formula normalization,
93 \item optional debug output,
94 \item optional shortcut commands,
95 \item optional built-in standard rules,
96 \item wrapper environments for proof trees.
97 \end{itemize}
98 \texttt{seqcalc} does not modify the layout logic of \texttt{bussproofs}. It only adds a structured interface on top. For exapmle usage see Section \ref{subsec:full_derivation}.
99
100 \section{Installation}
101 \subsection{Files}
102 This work currently consists of a single file:
103 \begin{itemize}
104 \item \texttt{seqcalc.sty}
105 \end{itemize}
106 Place this file somewhere in your \TeX{} tree where \LaTeX{} can find it, for example, in a local directory searched by your distribution or in the same directory as your document.
107
108 \subsection{Loading the package}
109 Load \texttt{seqcalc}:
110 \begin{lstlisting}
111 \usepackage{seqcalc}
112 \end{lstlisting}
113 You may also pass options to \texttt{seqcalc}, as
114 described in Section~\ref{sec:options}.
115
116 \section{Package options}
117 \label{sec:options}
118 Package options are implemented using \texttt{l3keys2e}. All options are optional and have sensible defaults. Options may be passed when loading the package:
119
120 \subsection{normalize-formulas}
121 \begin{description}
122 \item[\texttt{normalize-formulas=<true|false>}]
123 Enables formula normalization. Default: \texttt{true}.
124 \end{description}
125 Normalization automatically removes redundant separators and whitespaces.
126 \begin{tcolorbox}[
127 seqexample,
128 title={Normalization example}
129 ]
130 \begin{lstlisting}
131 \seq{A, , , B;;C}{D}
132 \end{lstlisting}
133 \tcblower
134 \seq{A, , , B;;C}{D}
135 \end{tcolorbox}
136
137 \subsection{debug}
138 \begin{description}
139 \item[\texttt{debug=<true|false>}]
140 Prints debug messages to the terminal. Default: \texttt{false}.
141 \end{description}
142 Example output:
143 \begin{lstlisting}
144 Package seqcalc [formula]: Normalized 'A;;B' to 'A,B'
145 Package seqcalc [rule]: Declaring rule AndR
146 \end{lstlisting}
147
148 \subsection{shortcuts}
149 \begin{description}
150 \item[\texttt{shortcuts=<true|false>}]
151 Enables compact aliases for proof constructs. Default: \texttt{false}.
152 \end{description}
153 Shortcuts may also be enabled at any point using \texttt{\textbackslash EnableSeqShortcuts}. A full list of shortcuts is given in Section~\ref{subsec:shortcuts}.
154
155 \subsection{standard-rules}
156 \begin{description}
157 \item[\texttt{standard-rules=<true|false>}]
158 Loads a built-in set of sequent calculus rules. Default: \texttt{false}.
159 \end{description}
160 Standard rules may also be enabled at runtime using \texttt{\textbackslash EnableSeqStandardRules}. The predefined rules are listed in Section~\ref{subsec:standard-rules}.
161
162 \section{Runtime commands}
163 \label{sec:commands}
164
165 \subsection{Sequents}
166 \begin{description}
167 \item[\texttt{\textbackslash seq\{A\}\{B\}}]
168 Typesets the sequent \seq{A}{B}.
169 \item[\texttt{\textbackslash seqL\{A\}}]
170 Typesets \seqL{A}.
171 \item[\texttt{\textbackslash seqR\{A\}}]
172 Typesets \seqR{A}.
173 \end{description}
174 The arguments \texttt{A} and \texttt{B} represent comma‑separated lists of formulas. If formula normalization is enabled, redundant separators, multiple commas, and superfluous whitespace are automatically removed.
175
176 \subsection{Axioms and premises} \begin{description}
177 \item[\texttt{\textbackslash SeqAxiom\{A\}}]
178 Inserts an axiom.
179 \item[\texttt{\textbackslash SeqPremise\{A\}}]
180 Inserts a premise.
181 \end{description}
182 Axioms and premises both introduce leaves in a proof tree. Axioms are closed leaves (overlined), while premises remain open.
183 See Section~\ref{subsec:conclusions} on conclusions for how axioms and premises are combined into inference steps.
184
185 \subsection{Conclusions}
186 \label{subsec:conclusions}
187 \begin{description}
188 \item[\texttt{\textbackslash
189 SeqConclusion[Label]\{Cmd\}\{Formula\}[Hint]}]
190 General conclusion command.
191 \item[\texttt{\textbackslash SeqConclusionU[Label]\{Formula\}[Hint]}]
192 Unary inference.
193 \item[\texttt{\textbackslash SeqConclusionB[Label]\{Formula\}[Hint]}]
194 Binary inference.
195 \end{description}
196 A conclusion introduces an inference step.\\
197 Arguments:
198 \begin{itemize}
199 \item \texttt{Label} (optional): text placed to the left of the inference bar, typically the name of a rule;
200 \item \texttt{Cmd}: a \texttt{bussproofs} inference command (\texttt{UnaryInfC}, \texttt{BinaryInfC}, \texttt{TrinaryInfC});
201 \item \texttt{Formula}: the conclusion formula;
202 \item \texttt{Hint} (optional): text placed to the right of the inference bar, often used for instantiation information or side conditions.
203 \end{itemize}
204
205 \subsection{Shortcuts}
206 \label{subsec:shortcuts}
207 When shortcut support is enabled (either via the package option \texttt{shortcuts=true} or by calling \texttt{\textbackslash EnableSeqShortcuts}), \texttt{seqcalc} defines a set of compact aliases for proof‑tree constructs. These shortcuts behave exactly like their long forms:
208 \begin{center}
209 \begin{tabular}{ll}
210 \toprule
211 \textbf{Shortcut} & \textbf{Expands to} \\
212 \midrule
213 \texttt{\textbackslash SeqAx} & \texttt{\textbackslash SeqAxiom} \\
214 \texttt{\textbackslash SeqPr} & \texttt{\textbackslash SeqPremise} \\
215 \texttt{\textbackslash Cc} & \texttt{\textbackslash SeqConclusion} \\
216 \texttt{\textbackslash CU} & \texttt{\textbackslash SeqConclusionU} \\
217 \texttt{\textbackslash CB} & \texttt{\textbackslash SeqConclusionB} \\
218 \bottomrule
219 \end{tabular}
220 \end{center}
221
222 \section{Environments}
223 \subsection{\texttt{seqproof}}
224 A wrapper around \texttt{prooftree}:
225 \begin{tcolorbox}[
226 seqexample,
227 title={\texttt{seqproof}}
228 ]
229 \begin{lstlisting}
230 \begin{seqproof}
231 \SeqPremise{A}
232 \SeqConclusionU{B}
233 \end{seqproof}
234 \end{lstlisting}
235 \tcblower
236 \begin{seqproof}
237 \SeqPremise{A}
238 \SeqConclusionU{B}
239 \end{seqproof}
240 \end{tcolorbox}
241
242 \subsection{\texttt{seqproofinline}}
243 A compact inline proof environment:
244 \begin{tcolorbox}[
245 seqexample,
246 title={\texttt{seqproofinline}}
247 ]
248 \begin{lstlisting}
249 Some text
250 \begin{seqproofinline}
251 \SeqPremise{A}
252 \SeqConclusionU{B}
253 \end{seqproofinline}
254 and some more text...
255 \end{lstlisting}
256 \tcblower
257 Some text
258 \begin{seqproofinline}
259 \SeqPremise{A}
260 \SeqConclusionU{B}
261 \end{seqproofinline}
262 and some more text...
263 \end{tcolorbox}
264 \noindent Inline proofs are useful when a full proof tree would interrupt the flow of text.\\
265 For complete examples demonstrating these environments in practice, see Section~\ref{sec:examples}.
266
267 \section{Rule system}
268 A rule in \texttt{seqcalc} is a named inference pattern specifying its arity (one, two, or three premises) and an optional display label. Once declared, a rule can be applied using \texttt{\textbackslash SeqRule} or via its automatically generated macro.
269
270 \subsection{Declaring rules}
271 Declare rules using:
272 \begin{lstlisting}
273 \SeqCalcDeclareRule{Name}{Premises}[Label]
274 \end{lstlisting}
275
276 \subsection{Applying rules}
277 Apply rules with:
278 \begin{lstlisting}
279 \SeqRule{Name}{Formula}[Hint]
280 \end{lstlisting}
281 Alternatively, once a rule has been declared, its name becomes a macro of its own:
282 \begin{lstlisting}
283 \Name{Formula}[Hint]
284 \end{lstlisting}
285
286 \subsection{Standard rules}
287 \label{subsec:standard-rules}
288
289 When the option \texttt{standard-rules=true} is used, or when \texttt{\textbackslash EnableSeqStandardRules} is called, the following
290 rules are predeclared:
291
292 \begin{center}
293 \begin{tabular}{lcc}
294 \toprule
295 \textbf{Rule} & \textbf{Arity} & \textbf{Label} \\
296 \midrule
297 \texttt{NegL} & 1 & $(\neg\Rightarrow)$ \\
298 \texttt{NegR} & 1 & $(\Rightarrow\neg)$ \\
299 \texttt{AndL} & 1 & $(\land\Rightarrow)$ \\
300 \texttt{AndR} & 2 & $(\Rightarrow\land)$ \\
301 \texttt{OrL} & 2 & $(\lor\Rightarrow)$ \\
302 \texttt{OrR} & 1 & $(\Rightarrow\lor)$ \\
303 \texttt{ImpL} & 2 & $(\to\Rightarrow)$ \\
304 \texttt{ImpR} & 1 & $(\Rightarrow\to)$ \\
305 \texttt{ForallL} & 1 & $(\forall\Rightarrow)$ \\
306 \texttt{ForallR} & 1 & $(\Rightarrow\forall)$ \\
307 \texttt{ExistsL} & 1 & $(\exists\Rightarrow)$ \\
308 \texttt{ExistsR} & 1 & $(\Rightarrow\exists)$ \\
309 \texttt{SubL} & 1 & $(S\Rightarrow)$ \\
310 \texttt{SubR} & 1 & $(\Rightarrow S)$ \\
311 \texttt{EqL} & 1 & $(\Rightarrow =)$ \\
312 \bottomrule
313 \end{tabular}
314 \end{center}
315 All standard rules can be applied either via \texttt{\textbackslash SeqRule} or directly through their shortcut macro, e.g.
316 \texttt{\textbackslash AndR\{B\}}.
317
318
319 \section{Examples}
320 \label{sec:examples}
321
322 This section demonstrates the functionality of \texttt{seqcalc} using examples.
323
324 \section{Minimal working example}
325 The following example demonstrates the basic usage of \texttt{seqcalc}
326 with a simple unary inference.
327
328 \subsection{Basic axiom and unary conclusion}
329 \begin{tcolorbox}[seqexample,title={Axiom and unary inference}]
330 \begin{lstlisting}
331 \begin{seqproof}
332 \SeqAxiom{A}
333 \SeqConclusionU{B}
334 \end{seqproof}
335 \end{lstlisting}
336 \tcblower
337 \begin{seqproof}
338 \SeqAxiom{A}
339 \SeqConclusionU{B}
340 \end{seqproof}
341 \end{tcolorbox}
342
343 \subsection{Binary conclusion}
344 \begin{tcolorbox}[seqexample,title={Binary conclusion}]
345 \begin{lstlisting}
346 \begin{seqproof}
347 \SeqPremise{A}
348 \SeqPremise{B}
349 \SeqConclusionB{A,B}
350 \end{seqproof}
351 \end{lstlisting}
352 \tcblower
353 \begin{seqproof}
354 \SeqPremise{A}
355 \SeqPremise{B}
356 \SeqConclusionB{A,B}
357 \end{seqproof}
358 \end{tcolorbox}
359
360 \subsection{Using shortcuts}
361 \begin{tcolorbox}[seqexample,title={Shortcuts enabled}]
362 \begin{lstlisting}
363 \EnableSeqShortcuts
364
365 \begin{seqproof}
366 \SeqAx{A}
367 \CU{B}
368 \end{seqproof}
369 \end{lstlisting}
370 \tcblower
371 \EnableSeqShortcuts
372 \begin{seqproof}
373 \SeqAx{A}
374 \CU{B}
375 \end{seqproof}
376 \end{tcolorbox}
377
378 \subsection{Declaring and applying a custom rule}
379 \begin{tcolorbox}[seqexample,title={Custom rule}]
380 \begin{lstlisting}
381 \SeqCalcDeclareRule{MyRule}{2}[\star]
382
383 \begin{seqproof}
384 \SeqPremise{A}
385 \SeqPremise{B}
386 \MyRule{A,B}[C]
387 \end{seqproof}
388 \end{lstlisting}
389 \tcblower
390 \SeqCalcDeclareRule{MyRule}{2}[\star]
391 \begin{seqproof}
392 \SeqPremise{A}
393 \SeqPremise{B}
394 \MyRule{A,B}[C]
395 \end{seqproof}
396 \end{tcolorbox}
397
398 \subsection{Using standard rules}
399 \begin{tcolorbox}[seqexample,title={Standard rule: AndR}]
400 \begin{lstlisting}
401 \EnableSeqStandardRules
402
403 \begin{seqproof}
404 \SeqPremise{A\Rightarrow B}
405 \SeqPremise{A\Rightarrow C}
406 \AndR{A\Rightarrow B\land C}
407 \end{seqproof}
408 \end{lstlisting}
409 \tcblower
410 \EnableSeqStandardRules
411 \begin{seqproof}
412 \SeqPremise{A\Rightarrow B}
413 \SeqPremise{A\Rightarrow C}
414 \AndR{A\Rightarrow B\land C}
415 \end{seqproof}
416 \end{tcolorbox}
417
418 \subsection{Using sequents in prooftree}
419 \begin{tcolorbox}[seqexample,title={Sequents in prooftree}]
420 \begin{lstlisting}
421 \begin{seqproof}
422 \SeqPremise{\seq{A}{B}}
423 \SeqConclusionU{\seqR{B, \lnot A}}
424 \end{seqproof}
425 \end{lstlisting}
426 \tcblower
427 \begin{seqproof}
428 \SeqPremise{\seq{A}{B}}
429 \SeqConclusionU{\seqR{B, \lnot A}}
430 \end{seqproof}
431 \end{tcolorbox}
432
433 \subsection{Declaring and applying a rule with sequents}
434 \begin{tcolorbox}[seqexample,title={Custom rule with sequents}]
435 \begin{lstlisting}
436 % Declare a binary rule "Cut"
437 \SeqCalcDeclareRule{Cut}{2}[\mathrm{Cut}]
438
439 \begin{seqproof}
440 \SeqPremise{\seq{A}{B}}
441 \SeqPremise{\seq{B}{C}}
442 \Cut{\seq{A}{C}}
443 \end{seqproof}
444 \end{lstlisting}
445 \tcblower
446 \SeqCalcDeclareRule{Cut}{2}[\mathrm{Cut}]
447 \begin{seqproof}
448 \SeqPremise{\seq{A}{B}}
449 \SeqPremise{\seq{B}{C}}
450 \Cut{\seq{A}{C}}
451 \end{seqproof}
452 \end{tcolorbox}
453
454 \subsection{Inline proof}
455 \begin{tcolorbox}[seqexample,title={Inline proof}]
456 \begin{lstlisting}
457 We can derive $B$ from $A$ using:
458 \begin{seqproofinline}
459 \SeqPremise{A}
460 \SeqConclusionU{B}
461 \end{seqproofinline}
462 which completes the argument.
463 \end{lstlisting}
464 \tcblower
465 We can derive $B$ from $A$ using:
466 \begin{seqproofinline}
467 \SeqPremise{A}
468 \SeqConclusionU{B}
469 \end{seqproofinline}
470 which completes the argument.
471 \end{tcolorbox}
472
473 \subsection{Full derivation:}
474 \label{subsec:full_derivation}
475 \begin{tcolorbox}[seqexample,title={Derivation of $A \land B \Rightarrow B \land A$}]
476 \begin{lstlisting}
477 \EnableSeqStandardRules
478
479 \begin{seqproof}
480 % Left branch
481 \SeqAxiom{\seq{A,B}{A}}
482
483 % Right branch
484 \SeqAxiom{\seq{A,B}{B}}
485
486 % Combine
487 \AndR{\seq{A,B}{B\land A}}
488 \AndL{\seq{A\land B}{B\land A}}
489 \end{seqproof}
490 \end{lstlisting}
491 \tcblower
492 \begin{seqproof}
493 % Left branch
494 \SeqAxiom{\seq{A,B}{A}}
495
496 % Right branch
497 \SeqAxiom{\seq{A,B}{B}}
498
499 % Combine
500 \AndR{\seq{A,B}{B\land A}}
501 \AndL{\seq{A\land B}{B\land A}}
502 \end{seqproof}
503 \end{tcolorbox}
504
505 \section{Implementation notes}
506
507 \begin{itemize}
508 \item The rule system is implemented using global token lists.
509 \item Formula normalization uses \texttt{l3regex}.
510 \item Proof environments wrap the original \texttt{bussproofs} environments.
511 \end{itemize}
512
513 \section{License and maintenance}
514
515 This work may be distributed and/or modified under the conditions of
516 the \emph{\LaTeX{} Project Public License} (LPPL), version 1.3c or any
517 later version. The latest version of this license is available at:
518 \begin{center}
519 \url{https://www.latex-project.org/lppl/}
520 \end{center}
521
522 \noindent This work has the LPPL maintenance status \emph{maintained}. The
523 current maintainer of this work is Julian (\href{https://github.com/lambdaphoenix}{lambdaphoenix}).
524 This work consists of the following files:
525 \begin{itemize}
526 \item \texttt{source/seqcalc.sty}
527 \item \texttt{doc/seqcalc-doc.tex} and the generated PDF
528 \item \texttt{testfiles/} (test suite for \texttt{l3build})
529 \item \texttt{build.lua} (build configuration)
530 \item \texttt{README.md}
531 \end{itemize}
532 \section{Project Information}
533
534 The \texttt{seqcalc} package is developed openly on GitHub.
535 Users are encouraged to report issues, request features, or contribute
536 improvements.
537
538 \subsection*{Repository}
539
540 \begin{itemize}
541 \item Project page:
542 \url{https://github.com/lambdaphoenix/seqcalc}
543 \item Issue tracker:
544 \url{https://github.com/lambdaphoenix/seqcalc/issues}
545 \end{itemize}
546 The repository contains the following components:
547 \begin{itemize}
548 \item \textbf{source/} - the package source file \texttt{seqcalc.sty}
549 \item \textbf{doc/} - the documentation source \texttt{seqcalc-doc.tex}
550 \item \textbf{testfiles/} - the l3build test suite (\texttt{.lvt} and \texttt{.tlg} files)
551 \item \textbf{build.lua} - the \texttt{l3build} configuration
552 \item \textbf{README.md} - project overview
553 \end{itemize}
554 The documentation PDF is generated from the files in \texttt{doc/}.
555
556 \subsection*{Bug reports and feature requests}
557
558 If you encounter unexpected behavior, incompatibilities, or missing
559 features, please open an issue on GitHub. When reporting a problem,
560 include:
561
562 \begin{itemize}
563 \item a minimal working example
564 \item your \LaTeX{} distribution and version
565 \item the package version number
566 \end{itemize}
567
568 \subsection*{Contributing}
569
570 Contributions are welcome. Pull requests should follow the existing code
571 style and include examples when appropriate.
572
573 \section{Change log}
574
575 \subsection*{v1.0 (2026/01/30)}
576
577 \begin{itemize}
578 \item Initial public version.
579 \item Rule declaration and application system.
580 \item Formula normalization.
581 \item Debug mode.
582 \item Shortcut system.
583 \item Standard rule set.
584 \end{itemize}
585
586 \end{document}