Skip to content

Commit 8cffe53

Browse files
committed
Add HW02 tex template
1 parent afa6ab2 commit 8cffe53

File tree

3 files changed

+188
-0
lines changed

3 files changed

+188
-0
lines changed

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.PHONY: all clean cleanall
2+
3+
all: hw02-student.pdf
4+
5+
%.pdf: %.tex
6+
latexmk -pdf $<
7+
8+
clean:
9+
latexmk -c
10+
cleanall:
11+
latexmk -C

hw02-student.pdf

84.8 KB
Binary file not shown.

hw02-student.tex

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
\documentclass[11pt]{exam}
2+
\usepackage[margin=1in]{geometry}
3+
\usepackage{amsmath,amsthm,amssymb}
4+
\usepackage{mathptmx}
5+
6+
\usepackage{xspace}
7+
\usepackage{tabularx}
8+
\usepackage{amsmath}
9+
\usepackage{mathpartir} %% for inference rules
10+
11+
%% Listings
12+
\usepackage{listings}
13+
\lstdefinestyle{default}{%
14+
basicstyle=\ttfamily,%
15+
commentstyle=\sl,%
16+
keywordstyle=\bf,%
17+
columns=fullflexible,%
18+
keepspaces=true,%
19+
mathescape%
20+
}
21+
\lstset{style=default}
22+
\newcommand{\ocaml}[1]{\lstset{language=[Objective]Caml}\lstinline~#1~}
23+
\lstnewenvironment{OCaml}
24+
{\lstset{language=[Objective]Caml}}
25+
{}
26+
27+
\title{Assignment 2: \\
28+
Language Design and Implementation}
29+
\date{Due: Friday, February 23, 2018}
30+
31+
\author{YOUR NAME}
32+
33+
%% Number questions by section
34+
\renewcommand{\thequestion}{\thesection.\arabic{question}}
35+
36+
%% toggle math mode and text mode for tabular and array
37+
\newcolumntype{C}{>{$}c<{$}}
38+
\newcolumntype{L}{>{$}l<{$}}
39+
\newcolumntype{R}{>{$}r<{$}}
40+
41+
\newcommand{\fmtkw}[1]{\mathtt{#1}}
42+
43+
\newcommand{\Typ}{\ensuremath{\mathsf{Typ}}}
44+
\newcommand{\typ}{\ensuremath{\mathit{\tau}}}
45+
\newcommand{\numtyp}{\ensuremath{\fmtkw{num}}}
46+
\newcommand{\booltyp}{\ensuremath{\fmtkw{bool}}}
47+
48+
\newcommand{\Expr}{\ensuremath{\mathsf{Exp}}}
49+
\newcommand{\expr}{\ensuremath{\mathit{e}}}
50+
51+
\newcommand{\addra}[1]{\ensuremath{\fmtkw{addr}[#1]}}
52+
\newcommand{\addr}{\ensuremath{\mathit{a}}}
53+
\newcommand{\numa}[1]{\ensuremath{\fmtkw{num}[#1]}}
54+
\newcommand{\num}{\ensuremath{\mathit{n}}}
55+
\newcommand{\boola}[1]{\ensuremath{\fmtkw{bool}[#1]}}
56+
\newcommand{\bool}{\ensuremath{\mathit{b}}}
57+
\newcommand{\plusa}[2]{\ensuremath{\fmtkw{plus}(#1; #2)}}
58+
\newcommand{\plusc}[2]{\ensuremath{#1 \mathbin{\fmtkw{+}} #2}}
59+
\newcommand{\timesa}[2]{\ensuremath{\fmtkw{times}(#1; #2)}}
60+
\newcommand{\timesc}[2]{\ensuremath{#1 \mathbin{\fmtkw{*}} #2}}
61+
\newcommand{\eqa}[2]{\ensuremath{\fmtkw{eq}(#1; #2)}}
62+
\newcommand{\eqc}[2]{\ensuremath{#1 \mathrel{\fmtkw{==}} #2}}
63+
\newcommand{\lea}[2]{\ensuremath{\fmtkw{le}(#1; #2)}}
64+
\newcommand{\lec}[2]{\ensuremath{#1 \mathrel{\fmtkw{<=}} #2}}
65+
\newcommand{\nota}[1]{\ensuremath{\fmtkw{not}(#1)}}
66+
\newcommand{\notc}[1]{\ensuremath{\mathord{\fmtkw{!}}#1}}
67+
\newcommand{\anda}[2]{\ensuremath{\fmtkw{and}(#1; #2)}}
68+
\newcommand{\andc}[2]{\ensuremath{#1 \mathbin{\fmtkw{\&\&}} #2}}
69+
\newcommand{\ora}[2]{\ensuremath{\fmtkw{or}(#1; #2)}}
70+
\newcommand{\orc}[2]{\ensuremath{#1 \mathbin{\fmtkw{||}} #2}}
71+
72+
\newcommand{\Cmd}{\ensuremath{\mathsf{Cmd}}}
73+
\newcommand{\cmd}{\ensuremath{\mathit{c}}}
74+
\newcommand{\skipa}{\ensuremath{\fmtkw{skip}}}
75+
\newcommand{\seta}[2]{\ensuremath{\fmtkw{set}[#1](#2)}}
76+
\newcommand{\setc}[2]{\ensuremath{#1 \mathrel{\fmtkw{:=}} #2}}
77+
\newcommand{\seqa}[2]{\ensuremath{\fmtkw{seq}(#1; #2)}}
78+
\newcommand{\seqc}[2]{\ensuremath{#1\fmtkw{;}\;#2}}
79+
\newcommand{\ifa}[3]{\ensuremath{\fmtkw{if}(#1; #2; #3)}}
80+
\newcommand{\ifc}[3]{\ensuremath{\fmtkw{if}\;#1\;\fmtkw{then}\;#2\;\fmtkw{else}\;#3}}
81+
\newcommand{\whilea}[2]{\ensuremath{\fmtkw{while}(#1; #2)}}
82+
\newcommand{\whilec}[2]{\ensuremath{\fmtkw{while}\;#1\;\fmtkw{do}\;#2}}
83+
84+
\newcommand{\Addr}{\ensuremath{\mathsf{Addr}}}
85+
86+
\newcommand{\store}{\ensuremath{\sigma}}
87+
\newcommand{\storelet}[2]{\ensuremath{#1 \hookrightarrow #2}}
88+
\newcommand{\xstore}[3]{#1, \storelet{#2}{#3}}
89+
90+
\newcommand{\IMP}{\textbf{\textsf{IMP}}\xspace}
91+
92+
\newcommand{\E}{\textbf{\textsf{E}}\xspace}
93+
\newcommand{\T}{\textbf{\textsf{T}}\xspace}
94+
\renewcommand{\P}{\textbf{\textsf{P}}\xspace}
95+
\renewcommand{\S}{\textbf{\textsf{S}}\xspace}
96+
\newcommand{\ET}{\textbf{\textsf{ET}}\xspace}
97+
\newcommand{\ETP}{\textbf{\textsf{ETP}}\xspace}
98+
\newcommand{\ETPS}{\textbf{\textsf{ETPS}}\xspace}
99+
100+
\newcommand{\state}[2]{\langle #1, #2 \rangle}
101+
102+
\newcommand{\hasType}[2]{\ensuremath{#1 : #2}}
103+
\newcommand{\hypJ}[2]{\ensuremath{#1 \vdash #2}}
104+
\newcommand{\isOk}[1]{\ensuremath{#1\;\mathsf{ok}}}
105+
\newcommand{\eval}[2]{\ensuremath{#1 \Downarrow #2}}
106+
\newcommand{\step}[2]{\ensuremath{#1 \longmapsto #2}}
107+
\newcommand{\stepspap}[3][\typ]{\ensuremath{#2 \hookrightarrow_{:#1} #3}}
108+
\newcommand{\isVal}[1]{\ensuremath{#1\;\mathsf{val}}}
109+
\newcommand{\isFinal}[1]{\ensuremath{#1\;\mathsf{final}}}
110+
111+
\newcommand{\even}{\operatorname{even}}
112+
113+
\pagestyle{plain}
114+
\begin{document}
115+
\maketitle
116+
117+
\section{Language Design: \IMP}
118+
119+
\begin{questions}
120+
\question
121+
\end{questions}
122+
123+
\section{Language Implementation: \ETPS}
124+
125+
See \texttt{hw02.ml} and \texttt{test\_hw02.ml}.
126+
127+
\section{Final Project Preparation: Pre-Proposal}
128+
129+
\begin{questions}
130+
\question
131+
\end{questions}
132+
133+
%% Appendix
134+
\clearpage
135+
\appendix
136+
137+
\section{Syntax of \IMP}
138+
139+
\[\begin{array}{lrcllL}
140+
\Typ & \typ & ::= & \numtyp & \numtyp & numbers
141+
\\
142+
&&& \booltyp & \booltyp & booleans
143+
\\
144+
\Expr & \expr & ::= & \addra{\addr} & \addr & addresses (or ``assignables'')
145+
\\
146+
&&& \numa{\num} & \num & numeral
147+
\\
148+
&&& \boola{\bool} & \bool & boolean
149+
\\
150+
&&& \plusa{\expr_1}{\expr_2} & \plusc{\expr_1}{\expr_2} & addition
151+
\\
152+
&&& \timesa{\expr_1}{\expr_2} & \timesc{\expr_1}{\expr_2} & multiplication
153+
\\
154+
&&& \eqa{\expr_1}{\expr_2} & \eqc{\expr_1}{\expr_2} & equal
155+
\\
156+
&&& \lea{\expr_1}{\expr_2} & \lec{\expr_1}{\expr_2} & less-than-or-equal
157+
\\
158+
&&& \nota{\expr_1} & \notc{\expr_1} & negation
159+
\\
160+
&&& \anda{\expr_1}{\expr_2} & \andc{\expr_1}{\expr_2} & conjunction
161+
\\
162+
&&& \ora{\expr_1}{\expr_2} & \orc{\expr_1}{\expr_2} & disjunction
163+
\\
164+
\Cmd & \cmd & ::= & \seta{\addr}{\expr} & \setc{\addr}{\expr} & assignment
165+
\\
166+
&&& \skipa & \skipa & skip
167+
\\
168+
&&& \seqa{\cmd_1}{\cmd_2} & \seqc{\cmd_1}{\cmd_2} & sequencing
169+
\\
170+
&&& \ifa{\expr}{\cmd_1}{\cmd_2} & \ifc{\expr}{\cmd_1}{\cmd_2} & conditional
171+
\\
172+
&&& \whilea{\expr}{\cmd_1} & \whilec{\expr}{\cmd_1} & looping
173+
\\
174+
\Addr & \addr
175+
\end{array}\]
176+
177+
\end{document}

0 commit comments

Comments
 (0)