-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlambda.sty
More file actions
149 lines (121 loc) · 4.28 KB
/
lambda.sty
File metadata and controls
149 lines (121 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
%
% A collection of our commonly used LaTeX macros.
%
\ProvidesPackage{lambda}
\RequirePackage{fancyvrb}
% \RequirePackage{mathptmx}
\RequirePackage{twoopt}
\newcommand{\LambdaVersion}{1.1}
%%%%%%%%%%%%%%
% Meta notes %
%%%%%%%%%%%%%%
% \NOTE{...} produces a large, obvious black box. Use \medskip within to break
% up paragraphs if needed. To make all note boxes invisible, add the following
% line after importing this file.
% \renewcommand{\NOTE}[1]{}
\newlength{\dummylen}
\newcommand{\NOTE}[1]{\setlength{\dummylen}{\fboxrule}\setlength{\fboxrule}{2pt}%
\vspace{1ex}\noindent\hfill%
\fbox{\begin{minipage}{.96\columnwidth}#1\end{minipage}}%
\setlength{\fboxrule}{\dummylen}\hfill{}\vspace{1ex}}
% in-line comments
\newcommand{\TODO}[1]{\ifdefined\color
{\color{red}[#1]}%
\else
{\emph{[#1]}}%
\fi}
%%%%%%%%%%
% Layout %
%%%%%%%%%%
% add after \begin{itemize|enumerate} for dense lists
\def\denseitems{
\itemsep1pt plus1pt minus1pt
\parsep0pt plus0pt
\parskip0pt\topsep0pt}
% add after \begin{itemize|enumerate} for sparse lists
\def\sparseitems{
\itemsep11pt plus1pt minus1pt
\parsep3pt plus0pt
\parskip3pt\topsep0pt}
%%%%%%%%%%%%%%%%%%%%%%
% Generic math stuff %
%%%%%%%%%%%%%%%%%%%%%%
% ensure math mode (what does OB stand for?)
\def\OB#1{\ifmmode#1\else\mbox{$#1$}\fi}
% \newcommand{\OB}[1]{\ensuremath{#1}}
%% multi-line definitions
\newcommand{\Begindef}{\ =\ \BegindefNES}
\newcommand{\BegindefNES}{\left\{\begin{array}{@{}l@{\quad}l}}
\newcommand{\Enddef}{\end{array}\right.}
\newcommand{\If}{\textrm{if\ }}
\newcommand{\Otherwise}{\textrm{otherwise}}
% sets and vectors
\newcommand{\set}[1]{\OB{\{#1\}}}
\newcommand{\setc}[2]{\set{#1\;|\;#2}}
\newcommand{\vect}[1]{\OB{\langle#1\rangle}}
% enumerations and indexing
\newcommand{\vij}[3]{\OB{#1_{#2},\ldots,#1_{#3}}}
\newcommand{\vi}[2]{\vij{#1}{1}{#2}}
\newcommand{\vn}[2][n]{\vi{#2}{#1}}
\newcommand{\vnButi}[3][n]{\OB{#2_1,\ldots,#2_{#3-1},#2_{#3+1},\ldots,#2_{#1}}}
\newcommand{\cseq}[2][n]{\OB{^{#2:1..#1}}}
\newcommand{\iPat}[2][i]{\OB{[#1\mathop:#2]}}
\newcommandtwoopt{\ijPat}[4][i][j]{\OB{[#1\mathop:#3,#2\mathop:#4]}}
% domain and range of mappings
\newcommand{\domSym}{\mathit{dom}}
\newcommand{\rngSym}{\mathit{rng}}
\newcommand{\dom}[1]{\OB{\domSym(#1)}}
\newcommand{\rng}[1]{\OB{\rngSym(#1)}}
% a shorter equal sign
%\RequirePackage{graphicx}
%\makeatletter
%\newcommand{\shorteq}{%
% \textrm{%
% \settowidth{\@tempdima}{--}%
% \resizebox{\@tempdima}{\height}{=}}}
%\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%
% Language design stuff %
%%%%%%%%%%%%%%%%%%%%%%%%%
% syntax/grammars
\newenvironment{syntax}{\[\begin{array}{rcl@{\quad}l}}
{\end{array}\]\ignorespacesafterend}
% semantics
%\RequirePackage{stmaryrd}
%\newcommand{\sem}[2][{}]{\OB{\semL#2\semR_{#1}}}
%\newcommand{\semL}{\llbracket}
%\newcommand{\semR}{\rrbracket}
% substitution
% order of arguments mirrors a let-expression:
% let v=e in e' ~> \subst{v}{e}{e'}
\newcommand{\subst}[3]{\OB{[#2/#1]#3}}
% contexts
\newcommand{\ctx}[2][C]{\OB{#1[#2]}}
% program/code environments
% a backslash character that works in program environments
\newcommand{\bs}{\texttt{\symbol{92}}}
% renew these commands to change the size and indentation of program text
\newcommand{\progind}{\parindent}
\newcommand{\progfontsize}{\small}
\newcommand{\progformat}{\tt}
% verbatim code + latex macros
\DefineVerbatimEnvironment{program}{Verbatim}
{xleftmargin=\progind,fontsize=\progfontsize,formatcom=\progformat,
commandchars=\\\{\},samepage=true}
\DefineVerbatimEnvironment{programNoCmdChr}{Verbatim}
{baselinestretch=1.0,xleftmargin=\progind,fontsize=\progfontsize,
samepage=true}
\DefineVerbatimEnvironment{sprogram}{Verbatim}
{xleftmargin=\progind,fontsize=\footnotesize,formatcom=\progformat,
commandchars=\\\{\},samepage=true}
\DefineVerbatimEnvironment{bprogram}{BVerbatim}
{fontsize=\progfontsize,formatcom=\progformat,
commandchars=\\\{\},samepage=true}
% non-verbatim code
\newcommand{\xx}{\phantom{xx}} % indent
\newenvironment{qprogram}
{\begin{list}{}{%
\setlength{\leftmargin}{\progind}}\item[]\ignorespaces}
{\unskip\end{list}}
% in-line code
\newcommand{\prog}[1]{\textrm{\progfontsize\progformat\texttt{#1}}}