algprog/tex/catprog.sty

238 lines
No EOL
8.2 KiB
TeX

%
% Standard macros to typeset papers on category theory and semantics
%
% Unless \catname is defined, make it bold.
% So, call \providecommand{\catname}{\mathcal}
% or \reprovidecommand{\catname}{\mathcal}
% before calling this file if you prefer calligraphic names for categories.
%
% Same applies to other commands.
%
% COPIED FROM https://gitlab.cs.fau.de/i8/TexCommon/ AND THEN ADJUSTED.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{catprog}[2024/03/30 Macros for Category Theory and Semantics]
\RequirePackage{bm} % Needed for defbbname
\RequirePackage{mathtools} % Needed for coloneqq
\providecommand{\catname}{\mathsf}
%\providecommand{\mndname}{\mathbbb}
\providecommand{\clsname}{\mathscr}
\providecommand{\oname}[1]{\operatorname{\mathsf{#1}}}
%% Defining category names like \BA, \BB, etc
\def\defcatname#1{\expandafter\def\csname B#1\endcsname{\catname{#1}}}
\def\defcatnames#1{\ifx#1\defcatnames\else\defcatname#1\expandafter\defcatnames\fi}
\defcatnames ABCDEFGHIJKLMNOPQRSTUVWXYZ\defcatnames
%% Defining \CA, \CB, etc
\def\defclsname#1{\expandafter\def\csname C#1\endcsname{\clsname{#1}}}
\def\defclsnames#1{\ifx#1\defclsnames\else\defclsname#1\expandafter\defclsnames\fi}
\defclsnames ABCDEFGHIJKLMNOPQRSTUVWXYZ\defclsnames
%% Defining \BBA, \BBB, etc
\def\defbbname#1{\expandafter\def\csname BB#1\endcsname{{\bm{\mathsf{#1}}}}}
\def\defbbnames#1{\ifx#1\defbbnames\else\defbbname#1\expandafter\defbbnames\fi}
\defbbnames ABCDEFGHIJKLMNOPQRSTUVWXYZ\defbbnames
%% Defining \BMA, \BMB, etc
\def\defbbname#1{\expandafter\def\csname BM#1\endcsname{{\bm{\mathsf{#1}}}}}
\def\defbbnames#1{\ifx#1\defbbnames\else\defbbname#1\expandafter\defbbnames\fi}
\defbbnames ABCDEFGHIJKLMNOPQRSTUVWXYZ\defbbnames
%% Some standard categories
\def\Set{\ensuremath{\catname{Set}}}
\def\Par{\ensuremath{\catname{Par}}}
\def\Rel{\ensuremath{\catname{Rel}}}
\def\Cpo{\ensuremath{\catname{Cpo}}}
\def\Pos{\ensuremath{\catname{Pos}}}
\def\Mon{\ensuremath{\catname{Mon}}}
\def\Gra{\ensuremath{\catname{Gra}}}
\providecommand{\Alg}[1]{\ensuremath{\catname{Alg}(#1)}}
\providecommand{\Coalg}[1]{\ensuremath{\catname{Coalg}(#1)}}
%% Objects of category
\providecommand{\obj}[1]{\ensuremath{\vert #1 \vert}}
%% Dual category
\providecommand{\dual}[1]{\ensuremath{#1^{op}}}
\providecommand{\ite}[3]{\oname{if}#1\oname{then}#2\oname{else}}
% Misc
%% Commutation of diagrams
\providecommand{\comm}{\circlearrowleft}
%% Banana brackets for catamorphisms
\RequirePackage{stmaryrd}
\providecommand{\cata}[1]{\llparenthesis #1 \rrparenthesis}
% Lens brackets for anamorphisms https://unicodeplus.com/U+3016
\providecommand{\ana}[1]{〖 #1 〗}
\providecommand{\dom}{\oname{dom}}
\providecommand{\eps}{{\operatorname\epsilon}}
\providecommand{\amp}{\mathbin{\&}}
\providecommand{\argument}{\operatorname{-\!-}}
\providecommand{\altargument}{\underline{\;\;}}
\providecommand{\wave}[1]{\widetilde{#1}} % Overline wave
\providecommand{\ul}{\underline} % Underline
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\providecommand{\mplus}{{\scriptscriptstyle\bf+}} % Small '+' for indexing
\providecommand{\smin}{\smallsetminus}
\providecommand{\ass}{\mathrel{\coloneqq}}
\providecommand{\bnf}{\mathrel{\Coloneqq}}
%% Some standard functorsw
\providecommand{\PSet}{{\mathcal P}} % Powerset
\providecommand{\FSet}{{\mathcal P}_{\omega}} % Finite powerset
\providecommand{\CSet}{{\mathcal P}_{\omega_1}} % Countable powerset
\providecommand{\NESet}{{\mathcal P}^{\mplus}} % Non-empty powerset
\providecommand{\Id}{\operatorname{Id}}
%% General categorical notation
\providecommand{\Hom}{\mathsf{Hom}}
\providecommand{\id}{\mathsf{id}}
\providecommand{\op}{\mathsf{op}}
\providecommand{\comp}{\mathbin{\circ}}
\providecommand{\iso}{\mathbin{\cong}}
\providecommand{\tensor}{\mathbin{\otimes}}
\providecommand{\unit}{\star}
\providecommand{\bang}{\operatorname!} % Terminal map
\providecommand{\cobang}{\operatorname¡} % Initial map
%% Various arrows
\providecommand{\from}{\leftarrow}
\providecommand{\ito}{\hookrightarrow} % Injection
\providecommand{\ifrom}{\hookleftarrow}
\providecommand{\pto}{\mathrel{\rightharpoonup}} % Partial function
\providecommand{\pfrom}{\mathrel{\leftarpoonup}} %
\providecommand{\tto}{\mathrel{\Rightarrow}} % Double arrow
\providecommand{\tfrom}{\mathrel{\Leftarrow}} %
\providecommand{\mto}{\mapsto}
\providecommand{\xto}[1]{\,\xrightarrow{#1}\,}
\providecommand{\xfrom}[1]{\,\xleftarrow{\;#1}\,}
\providecommand{\To}{\mathrel{\Rightarrow}} % Double arrow
\providecommand{\From}{\mathrel{\Leftarrow}}
\providecommand{\dar}{\kern-.75pt\operatorname{\downarrow}}
\providecommand{\uar}{\kern-.75pt\operatorname{\uparrow}}
\providecommand{\Dar}{\kern-.75pt\operatorname{\Downarrow}}
\providecommand{\Uar}{\kern-.75pt\operatorname{\Uparrow}}
%% Logic
\providecommand{\True}{\top}
\providecommand{\False}{\bot}
\providecommand{\bigor}{\bigvee}
\providecommand{\bigand}{\bigwedge}
\providecommand{\impl}{\Rightarrow}
\providecommand{\equ}{\Longleftrightarrow}
\providecommand{\entails}{\vdash}
%% Order
\providecommand{\appr}{\sqsubseteq}
\providecommand{\join}{\sqcup}
\providecommand{\meet}{\sqcap}
\providecommand{\bigjoin}{\bigsqcup}
\providecommand{\bigmeet}{\bigsqcap}
%% Products
\providecommand{\fst}{\pi_1}
\providecommand{\snd}{\pi_2}
\providecommand{\pr}{\oname{pr}}
\providecommand{\brks}[1]{\langle #1\rangle}
\providecommand{\Brks}[1]{\bigl\langle #1\bigr\rangle}
%% Coproducts
\providecommand{\inl}{\oname{i}_1}
\providecommand{\inr}{\oname{i}_2}
\providecommand{\inj}{\oname{in}}
\DeclareSymbolFont{Symbols}{OMS}{cmsy}{m}{n}
\DeclareMathSymbol{\iobj}{\mathord}{Symbols}{"3B}
%\DeclareRobustCommand{\iobj}{\emptyset}
%% CCC
\providecommand{\curry}{\oname{curry}}
\providecommand{\uncurry}{\oname{uncurry}}
\providecommand{\ev}{\oname{ev}}
% Semantic brackets
\RequirePackage{stmaryrd}
\providecommand{\lsem}{\llbracket}
\providecommand{\rsem}{\rrbracket}
\providecommand{\sem}[1]{\lsem #1 \rsem}
\providecommand{\Lsem}{\bigl\llbracket}
\providecommand{\Rsem}{\bigr\rrbracket}
\providecommand{\Sem}[1]{\Lsem #1 \Rsem}
% Typographic
\providecommand{\comma}{,\operatorname{}\linebreak[1]} % possibly line-breaking comma
\providecommand{\dash}{\nobreakdash-\hspace{0pt}} % non-line-breaking hyphen
\providecommand{\erule}{\rule{0pt}{0pt}} % Empty object whose emptiness
% is not detected by LaTeX
\providecommand{\by}[1]{\text{/\!\!/~#1}} % Comments in equations
\providecommand{\pacman}[1]{} % Hide a piece of text
\newcommand{\undefine}[1]{\let #1\relax} % Make a command undefined
\providecommand{\noqed}{\def\qed{}} % Undefine the QED symbol
% -1 superscript for the inversion operator
\providecommand{\mone}{{\text{\kern.5pt\rmfamily-}\mathsf{\kern-.5pt1}}}
\makeatletter
\@ifpackageloaded{enumitem}{}{
\RequirePackage[loadonly]{enumitem} % without [loadonly]
} % conflicts with Beamer
\makeatother
% Condensed list environments
\newlist{citemize}{itemize}{1}
\setlist[citemize]{label=\labelitemi,wide}
%leftmargin=0cm,itemindent=.7cm,labelwidth=\itemindent,labelsep=-.3cm,align=left}
\newlist{cenumerate}{enumerate}{1}
\setlist[cenumerate,1]{label=\arabic*.~,ref={\arabic*},wide}
%leftmargin=0cm,itemindent=.7cm,labelwidth=\itemindent,labelsep=-.3cm,align=left}
%\newenvironment{citemize}{\begin{itemize}[leftmargin=0cm,itemindent=.7cm,labelwidth=\itemindent,labelsep=-.3cm,align=left]}{\end{itemize}}
%\newenvironment{cenumerate}{\begin{enumerate}[leftmargin=0cm,itemindent=.7cm,labelwidth=\itemindent,labelsep=-.3cm,align=left]}{\end{enumerate}}
%% A macro for defining mixfix operators
\makeatletter
\def\mfix#1{\oname{#1}\@ifnextchar\bgroup\@mfix{}} % processing odd arguments
\def\@mfix#1{#1\@ifnextchar\bgroup\mfix{}} % processing even arguments
\makeatother
% %% Instances if mfix
% \providecommand{\ift}[3]{\mfix{if}{\mathbin{}#1}{then}{\mathbin{}#2}{else}{\mathbin{}#3}}
% \providecommand{\case}[3]{\mfix{case}{\mathbin{}#1}{of}{#2}{\kern-1pt;}{\mathbin{}#3}}
%%% Overwrite greek letters with var versions https://tex.stackexchange.com/a/304576/292879
\AfterBeginDocument{
\renewcommand{\epsilon}{\varepsilon}
\renewcommand{\theta}{\vartheta}
\renewcommand{\theta}{\vartheta}
\renewcommand{\kappa}{\varkappa}
\renewcommand{\rho}{\varrho}
\renewcommand{\phi}{\varphi}
}
%%%