Skip to content

Commit

Permalink
Separate style/shortcuts into class and package
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrieb committed Mar 27, 2020
1 parent 7274d4b commit 60d8c54
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 53 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ LATEX-DIR := $$HOME/texmf/tex/latex/local
.PHONY: install
install: homework.cls
mkdir -p $(LATEX-DIR)
cp hw-shortcuts.sty $(LATEX-DIR)
cp homework.cls $(LATEX-DIR)
@echo Homework template installed in $(LATEX-DIR)/homework.cls
Binary file modified example.pdf
Binary file not shown.
33 changes: 24 additions & 9 deletions example.tex
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
\documentclass[name=Jacob\ Strieb, andrewid=jstrieb, course=69-420, num=8]{homework}
\documentclass[name=Jacob\ Strieb, andrewid=jstrieb, course=69-420, num=4]{homework}

\usepackage{hw-shortcuts}

\begin{document}

\problem{1}
\problem{1a}

\begin{claim}
The set of rational numbers ($\Q$) is countable.
\end{claim}
\begin{proof}
Let $x \in \Q$. Then, by definition, we can write $x = \frac{a}{b}$ for some $a, b \in \Z$. This fraction can be uniquely mapped to a tuple $(a, b) \in \Z \times \Z$. This means that there exists an injective mapping $\Q \to \Z \times \Z$ that maps each fraction to a tuple. Thus, we have:
Let $x \in \Q$. Then, by definition, we can write $x = \frac{a}{b}$ for some $a, b \in \Z, b \neq 0$. This fraction can be uniquely mapped to a tuple $(a, b) \in \Z \times \Z$. This means that there exists an injective mapping $\Q \to \Z \times \Z$ that maps each fraction to a tuple. Thus, we have:
$$ |\Q| \leq |\Z \times \Z| \leq |\N| $$

By the countability of $|\N|$, we have shown that $\Q$ is countable.
By the countability of $\N$, we have shown that $\Q$ is countable.
\end{proof}
\newpage

\problem2
\separator

\problem{1b}
Let $E$ be an event, and let $1_E : \Omega \to \{ 0, 1 \}$ be an indicator random variable such that:
$$ 1_E(\omega) = \begin{cases}
1 & \omega \in E \\
Expand All @@ -36,7 +39,7 @@
\end{proof}
\newpage

\problem3
\problem2

\begin{claim}
$e^{iy} = \cos y + i \sin y$ for $y \in \R$
Expand All @@ -55,6 +58,18 @@
\end{proof}
\newpage

\problem{3}
\begin{claim}
$\P \neq \NP$
\end{claim}

\begin{proof}
We have already shown that $\P \subseteq \NP$, so to prove that $\NP \neq \P$ it suffices to show that $\NP \not \subseteq \P$. We begin by fixing a language $L \in \NP$.

\todo % TODO: Complete this problem later
\end{proof}
\newpage

\problem4

\begin{claim}
Expand All @@ -64,9 +79,9 @@
\begin{proof}
First, we pick and order $k$ cards to be matched. The probability of the selected card orders matching is $\frac{1}{k!}$.

Now, we consider the probability that the remaining $n - k$ cards \textit{do not} match. Similar to the examples from class and the textbook, this is an instance of an indexed union of sets $A_i \in \mathcal{F}$ such that $A_i$ is the set of permutations in which $f(i) = i$. But since we are looking for the probability of this not happening, we consider the probability of the complement, computed as 1 minus the probability of this union of events.
Now, we consider the probability that the remaining $n - k$ cards \textit{do not} match. Similar to the examples from class and the textbook, this is an instance of an indexed union of sets $A_i \in \mathcal{F}$ such that $A_i$ is the set of permutations in which $f(i) = i$. But since we are looking for the probability of this not happening, we consider the probability of the complement, computed as $1$ minus the probability of this union of events.

By the Inclusion-Exclusion principle, based on the notes from class, we have that
By the Inclusion-Exclusion principle, based on the notes from class, we have that:
$$ \prob{ \bigcup_{i = 1}^{n - k} A_i } = \sum_{i = 1}^{n - k} \frac{(-1)^i}{i!} $$

Putting everything together, we get the following, and we're done.
Expand Down
53 changes: 9 additions & 44 deletions homework.cls
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
\LoadClass{article}


%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Package options and document metadata
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{xkeyval}

Expand Down Expand Up @@ -46,9 +46,9 @@
\author{\name}


%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Imports and formatting
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Set the page on letter paper with microtype improvements and better list formatting
\RequirePackage[letterpaper]{geometry}
Expand Down Expand Up @@ -79,9 +79,9 @@
\titlespacing{\section}{0em}{0em}{1em}


%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Custom commands -- words, environments, and formatting
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Headers for numbered problems
\newcommand{\problem}[1]{\section{Problem #1}}
Expand All @@ -96,9 +96,9 @@
\newenvironment{claim}{\textit{Claim.}}{\vspace{-1em}}


%%%%
% Custom commands -- redefined
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Custom commands -- redefined commands that should look or behave differently
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Redefine the ampersand to use the italic version by default - as-per Elements of Typographic Style
% See: https://tex.stackexchange.com/a/47353/150811
Expand All @@ -121,38 +121,3 @@
% Redefine the bar and vec commands to use larger overlines and bold-faced vectors
\renewcommand{\bar}{\overline}
\renewcommand{\vec}{\mathbf}


%%%%
% Custom commands -- math symbols and math shortcuts
%%%%

% Shortcuts for left/right parentheses, square brackets, and curly braces
\newcommand{\lrp}[1]{\left( #1 \right)}
\newcommand{\lrs}[1]{\left[ #1 \right]}
\newcommand{\lrc}[1]{\left{ #1 \right}}

% Commonly-used sets
\newcommand{\N}{\ensuremath{\mathbb{N}}}
\newcommand{\Z}{\ensuremath{\mathbb{Z}}}
\newcommand{\R}{\ensuremath{\mathbb{R}}}
\newcommand{\Q}{\ensuremath{\mathbb{Q}}}
\newcommand{\C}{\ensuremath{\mathbb{C}}}

% Powerset and shortcut for derivative
\newcommand{\powerset}{\ensuremath{\mathcal{P}}}
\newcommand{\ddx}{\ensuremath{\frac{d}{dx}}}

% Probability measure, expectation, and variance formatting
\newcommand{\expect}[1]{\mathbb{E}\left[ #1 \right]}
\newcommand{\prob}[1]{\mathbb{P}\left[ #1 \right]}
\newcommand{\var}[1]{\mathrm{var}\left( #1 \right)}

% Commonly-used computer science languages
\renewcommand{\P}{\ensuremath{\mathsf{P}}}
\newcommand{\NP}{\ensuremath{\mathsf{NP}}}
\newcommand{\coNP}{\ensuremath{\mathsf{coNP}}}

% Commonly-used reductions add semantic clarity
\newcommand{\CookReducesTo}{\ensuremath{\leq^P_T}}
\newcommand{\KarpReducesTo}{\ensuremath{\leq^P_m}}
37 changes: 37 additions & 0 deletions hw-shortcuts.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
% Required for TeX packages
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{hw-shortcuts}[2020/03/27 Custom homework shortcuts as a package]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Custom commands -- math symbols and math shortcuts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Shortcuts for left/right parentheses, square brackets, and curly braces
\newcommand{\lrp}[1]{\left( #1 \right)}
\newcommand{\lrs}[1]{\left[ #1 \right]}
\newcommand{\lrc}[1]{\left{ #1 \right}}

% Commonly-used sets
\newcommand{\N}{\ensuremath{\mathbb{N}}}
\newcommand{\Z}{\ensuremath{\mathbb{Z}}}
\newcommand{\R}{\ensuremath{\mathbb{R}}}
\newcommand{\Q}{\ensuremath{\mathbb{Q}}}
\newcommand{\C}{\ensuremath{\mathbb{C}}}

% Powerset and shortcut for derivative
\newcommand{\powerset}{\ensuremath{\mathcal{P}}}
\newcommand{\ddx}{\ensuremath{\frac{d}{dx}}}

% Probability measure, expectation, and variance formatting
\newcommand{\expect}[1]{\mathbb{E}\left[ #1 \right]}
\newcommand{\prob}[1]{\mathbb{P}\left[ #1 \right]}
\newcommand{\var}[1]{\mathrm{var}\left( #1 \right)}

% Commonly-used computer science languages
\renewcommand{\P}{\ensuremath{\mathsf{P}}}
\newcommand{\NP}{\ensuremath{\mathsf{NP}}}
\newcommand{\coNP}{\ensuremath{\mathsf{coNP}}}

% Commonly-used reductions add semantic clarity
\newcommand{\CookReducesTo}{\ensuremath{\leq^P_T}}
\newcommand{\KarpReducesTo}{\ensuremath{\leq^P_m}}

0 comments on commit 60d8c54

Please sign in to comment.