diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..d86bf7b --- /dev/null +++ b/Readme.md @@ -0,0 +1 @@ +Cheatsheets built with reference from [jovyntls/cheatsheets](https://github.com/jovyntls/cheatsheets). Thanks for the great work and reference latex formatting! diff --git a/cheatsheets/cs1231s/1231num.sty b/cheatsheets/cs1231s/1231num.sty new file mode 100644 index 0000000..9e3820e --- /dev/null +++ b/cheatsheets/cs1231s/1231num.sty @@ -0,0 +1,601 @@ +%% This is file `1231num.sty', +%% Copyright (C) 2021 by Tin Lok Wong +%% +%% This work may be distributed and/or modified under the conditions +%% of the LaTeX Project Public License, either version 1.3 of this +%% license or (at your option) any later version. The latest version +%% of this license is in +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Tin Lok Wong. +%% +%% File last modified: 2021/10/06 + +% If hyperref is needed, then load it first. + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{1231num}[2021/02/26 v0.0 CS1231 line numbers] + +\RequirePackage{amsmath}% to align in math +\RequirePackage{tabto}% for starting a pfarray mid-line + +\newlength{\numpf@templen} + +\let\pfln\item +\let\lnref\ref + +% Parameters that controls the margins for proofs +\newlength{\pfmargin} \setlength{\pfmargin}{1em} +\newlength{\pflabelwdI} \setlength{\pflabelwdI}{1.2em} +\newlength{\pflabelwdII} \setlength{\pflabelwdII}{2.0em} +\newlength{\pflabelwdIII}\setlength{\pflabelwdIII}{2.8em} +\newlength{\pflabelwdIV} \setlength{\pflabelwdIV}{3.6em} +\newlength{\pflabelwdV} \setlength{\pflabelwdV}{4.4em} +\newlength{\pflabelwdi} +\newlength{\pflabelwdii} +\newlength{\pflabelwdiii} +\newlength{\pflabelwdiv} +\newlength{\pflabelwdv} +% Define the usual spacing around and within proofs. +\def\numpf@seti{% + \def\@listi{\leftmargin\pflabelwdi + \advance\leftmargin\labelsep + \labelwidth\pflabelwdi + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} +\def\numpf@setii{% + \def\@listii{\leftmargin\pflabelwdii + \advance\leftmargin\labelsep + \labelwidth\pflabelwdii + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} +\def\numpf@setiii{% + \def\@listiii{\leftmargin\pflabelwdiii + \advance\leftmargin\labelsep + \labelwidth\pflabelwdiii + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} +\def\numpf@setiv{% + \def\@listiv {\leftmargin\pflabelwdiv + \advance\leftmargin\labelsep + \labelwidth\pflabelwdiv + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} +\def\numpf@setv{% + \def\@listv {\leftmargin\pflabelwdv + \advance\leftmargin\labelsep + \labelwidth\pflabelwdv + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} +% Alternative set of spacing that saves more space. +\def\numpf@seti@star{% + \def\@listi{\leftmargin\z@ + \labelwidth\pflabelwdi + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep \z@}% +} +\def\numpf@setii@star{% + \def\@listii{\leftmargin\pfmargin + \labelwidth\pflabelwdii + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} +\def\numpf@setiii@star{% + \def\@listiii{\leftmargin\pfmargin + \labelwidth\pflabelwdiii + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} +\def\numpf@setiv@star{% + \def\@listiv {\leftmargin\pfmargin + \labelwidth\pflabelwdiv + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} +\def\numpf@setv@star{% + \def\@listv {\leftmargin\pfmargin + \labelwidth\pflabelwdv + \topsep \z@ + \parsep \z@ + \itemsep \z@ + \partopsep\z@}% +} + +% There are several places in which +% things with beamer are different from standand LaTeX: +% - the max depth of enumerate allowed; +% - the way enumerate displays the numbering; +% - the macros used to display the numbers; +% - the need to specify colours and fonts with beamer; +% - overlay options are available with beamer; +% - beamer sets additional parameters when entering a new enumerate. +\@ifclassloaded{beamer}{% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Definitions for standard BEAMER % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Here I increase the max depth of the enumerate environment. +% Modified from beamerbaselocalstructure.sty + \@definecounter{enumiv} + \@definecounter{enumv} + \setlength\leftmarginiv{2em} + \setlength\leftmarginv {2em} + \def\@listiv {\leftmargin\leftmarginiv + \labelwidth\leftmarginiv + \advance\labelwidth-\labelsep} + \def\@listv {\leftmargin\leftmarginv + \labelwidth\leftmarginv + \advance\labelwidth-\labelsep} + \def\numpf@enumerate{% + \ifnum\@enumdepth>4\relax\@toodeep + \else% + \advance\@enumdepth\@ne% + \edef\@enumctr{enum\romannumeral\the\@enumdepth}% + \advance\@itemdepth\@ne% + \fi% + \beamer@computepref\@enumdepth% sets \beameritemnestingprefix + \edef\beamer@enumtempl{enumerate \beameritemnestingprefix item}% + \@ifnextchar[{\beamer@@enum@}{\beamer@enum@}} + \let\endnumpf@enumerate\endenumerate + \def\beamer@computepref#1{% + \let\beameritemnestingprefix\@empty% + \ifcase#1\or\or\def\beameritemnestingprefix{sub}\or + \def\beameritemnestingprefix{subsub}\or + \def\beameritemnestingprefix{subsubsub}\or + \def\beameritemnestingprefix{subsubsubsub}\or + \@toodeep\fi} + \def\insertsubsubsubenumlabel{\theenumiv} + \def\insertsubsubsubsubenumlabel{\theenumv} +% Modified from beamercolorthemedefault.sty + \setbeamercolor{subsubsubitem}{parent=subsubitem} + \setbeamercolor{subsubsubsubitem}{parent=subsubsubitem} + \setbeamercolor{enumerate subsubsubitem}{parent=subsubsubitem} + \setbeamercolor{enumerate subsubsubsubitem}{parent=subsubsubsubitem} +% Modified from beamerfontthemedefault.sty + \setbeamerfont{enumerate subsubsubitem}{parent=subsubsubitem} + \setbeamerfont{enumerate subsubsubsubitem}{parent=subsubsubsubitem} + \setbeamerfont{itemize/enumerate body}{} + \setbeamerfont{itemize/enumerate subbody}{size=\normalfont} + \setbeamerfont{itemize/enumerate subsubbody}{size=\normalfont} + \setbeamerfont{itemize/enumerate subsubsubbody}{size=\normalfont} + \setbeamerfont{itemize/enumerate subsubsubsubbody}{size=\normalfont} + \setbeamercolor{enumerate subsubsubbody}{} + \setbeamercolor{enumerate subsubsubsubbody}{} +% Modified from beamerinnerthemedefault.sty + \defbeamertemplate*{enumerate subsubsubitem}{default} + {\usebeamertemplate*{enumerate subsubitem}\insertsubsubsubenumlabel.} + \defbeamertemplate*{enumerate subsubsubsubitem}{default} + {\usebeamertemplate*{enumerate subsubsubitem}\insertsubsubsubsubenumlabel.} + \defbeamertemplate*{enumerate subsubsubbody begin}{default}{} + \defbeamertemplate*{enumerate subsubsubbody end}{default}{} + \defbeamertemplate*{enumerate subsubsubsubbody begin}{default}{} + \defbeamertemplate*{enumerate subsubsubsubbody end}{default}{} +% The proof environments in text mode + \newenvironment{numpf} + {\numpf@ + \begin{subpf}} + {\end{subpf}\ignorespacesafterend} + \newenvironment{numpf*} + {\numpf@ + \begin{subpf*}} + {\end{subpf*}\ignorespacesafterend} + \newcommand{\numpf@}{% +% Modified from beamerbaselocalstructure.sty to make left-aligned numbers + \def\beamer@enum@{% + \beamer@computepref\@itemdepth% sets \beameritemnestingprefix + \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}% + \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}% + \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}% + \expandafter + \list + {\usebeamertemplate{\beamer@enumtempl}} + {\usecounter\@enumctr% + \def\makelabel####1{{\hss\rlap{{% + \usebeamerfont*{enumerate \beameritemnestingprefix item}% + \usebeamercolor[fg]{enumerate \beameritemnestingprefix item}####1}}}\hfill}}% + \beamer@cramped% + \raggedright% + \beamer@firstlineitemizeunskip}% +% Modified from beamerinnerthemedefault.sty + \setbeamertemplate{enumerate item}{\insertenumlabel.}% + \setbeamertemplate{enumerate subitem} + {\usebeamertemplate*{enumerate item}\insertsubenumlabel.}% + \setbeamertemplate{enumerate subsubitem} + {\usebeamertemplate*{enumerate subitem}\insertsubsubenumlabel.}% + \setbeamertemplate{enumerate subsubsubitem} + {\usebeamertemplate*{enumerate subsubitem}\insertsubsubsubenumlabel.}% + \setbeamertemplate{enumerate subsubsubsubitem} + {\usebeamertemplate*{enumerate subsubsubitem}\insertsubsubsubsubenumlabel.}% + \renewcommand{\theenumi}{\arabic{enumi}}% + \renewcommand{\theenumii}{\arabic{enumii}}% + \renewcommand{\theenumiii}{\arabic{enumiii}}% + \renewcommand{\theenumiv}{\arabic{enumiv}}% + \renewcommand{\theenumv}{\arabic{enumv}}% + \renewcommand{\p@enumi}{}% + \renewcommand{\p@enumii}{\theenumi.}% + \renewcommand{\p@enumiii}{\p@enumii\theenumii.}% + \renewcommand{\p@enumiv}{\p@enumiii\theenumiii.}% + \renewcommand{\p@enumv}{\p@enumiv\theenumiv.}% + \ifcase\@enumdepth + \setlength\pflabelwdi{\pflabelwdI}% + \setlength\pflabelwdii{\pflabelwdII}% + \setlength\pflabelwdiii{\pflabelwdIII}% + \setlength\pflabelwdiv{\pflabelwdIV}% + \setlength\pflabelwdv{\pflabelwdV}% + \or + \setlength\pflabelwdii{\pflabelwdI}% + \setlength\pflabelwdiii{\pflabelwdII}% + \setlength\pflabelwdiv{\pflabelwdIII}% + \setlength\pflabelwdv{\pflabelwdIV}% + \setbeamertemplate{enumerate subitem}{\insertsubenumlabel.}% + \renewcommand{\p@enumii}{}% + \or + \setlength\pflabelwdiii{\pflabelwdI}% + \setlength\pflabelwdiv{\pflabelwdII}% + \setlength\pflabelwdv{\pflabelwdIII}% + \setbeamertemplate{enumerate subsubitem}{\insertsubsubenumlabel.}% + \renewcommand{\p@enumiii}{}% + \or + \setlength\pflabelwdiv{\pflabelwdI}% + \setlength\pflabelwdv{\pflabelwdII}% + \setbeamertemplate{enumerate subsubsubitem}{\insertsubsubsubenumlabel.}% + \renewcommand{\p@enumiv}{}% + \or + \setlength\pflabelwdv{\pflabelwdI}% + \setbeamertemplate{enumerate subsubsubsubitem}{\insertsubsubsubsubenumlabel.}% + \renewcommand{\p@enumv}{}% + \fi} + \newenvironment{subpf} + {\advance\@enumdepth1 + \csname numpf@set\romannumeral\the\@enumdepth\endcsname + \advance\@enumdepth-1 + \begin{numpf@enumerate}} + {\end{numpf@enumerate}\ignorespacesafterend} + \newenvironment{subpf*} + {\advance\@enumdepth1 + \csname numpf@set\romannumeral\the\@enumdepth @star\endcsname + \advance\@enumdepth-1 + \begin{numpf@enumerate}} + {\end{numpf@enumerate}\ignorespacesafterend} + \newcommand{\linenum} + {\usebeamertemplate*{\beamer@enumtempl}} +% The \relax seems to help avoid an error +% if the immediately preceding \item has an overlay specification. + \newenvironment<>{pfarray}[1] + {\begin{uncoverenv}#2\pfln\relax\numpf@rray{#1}} + {\endarray\end{math}\end{uncoverenv}\ignorespacesafterend} + \newcommand{\subpfalign@@set}{% + \advance\@enumdepth\@ne + \setcounter{enum\romannumeral\the\@enumdepth}{1}% + \beamer@computepref\@enumdepth% sets \beameritemnestingprefix + \edef\beamer@enumtempl{enumerate \beameritemnestingprefix item}% + \let\numpf@amsmathLet@\Let@ + \def\Let@{\let\\\numpf@spf@lignlb}} +}{% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Definitions for standard LaTeX % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Here I define one more layer for the numpf environment. + \@definecounter{enumv} +% Modified from report.cls + \renewcommand\theenumv{\@Roman\c@enumv} + \newcommand\labelenumv{\theenumv.} + \renewcommand\p@enumv{\p@enumiv\theenumiv} +% The proof environments in text mode + \newenvironment{numpf} + {\numpf@ + \begin{subpf}} + {\end{subpf}\ignorespacesafterend} + \newenvironment{numpf*} + {\numpf@ + \begin{subpf*}} + {\end{subpf*}\ignorespacesafterend} + \newcommand{\numpf@}{% + \renewcommand\labelenumi{\theenumi.}% + \renewcommand\theenumi{\arabic{enumi}}% + \renewcommand\p@enumi{}% + \renewcommand\labelenumii{\labelenumi\theenumii.}% + \renewcommand\theenumii{\arabic{enumii}}% + \renewcommand\p@enumii{\p@enumi\theenumi.}% + \renewcommand\labelenumiii{\labelenumii\theenumiii.}% + \renewcommand\theenumiii{\arabic{enumiii}}% + \renewcommand\p@enumiii{\p@enumii\theenumii.}% + \renewcommand\labelenumiv{\labelenumiii\theenumiv.}% + \renewcommand\theenumiv{\arabic{enumiv}}% + \renewcommand\p@enumiv{\p@enumiii\theenumiii.}% + \renewcommand\labelenumv{\labelenumiv\theenumv.}% + \renewcommand\theenumv{\arabic{enumv}}% + \renewcommand\p@enumv{\p@enumiv\theenumiv.}% + \ifcase\@enumdepth + \setlength\pflabelwdi{\pflabelwdI}% + \setlength\pflabelwdii{\pflabelwdII}% + \setlength\pflabelwdiii{\pflabelwdIII}% + \setlength\pflabelwdiv{\pflabelwdIV}% + \setlength\pflabelwdv{\pflabelwdV}% + \or + \setlength\pflabelwdii{\pflabelwdI}% + \setlength\pflabelwdiii{\pflabelwdII}% + \setlength\pflabelwdiv{\pflabelwdIII}% + \setlength\pflabelwdv{\pflabelwdIV}% + \renewcommand\labelenumii{\theenumii.}% + \renewcommand{\p@enumii}{}% + \or + \setlength\pflabelwdiii{\pflabelwdI}% + \setlength\pflabelwdiv{\pflabelwdII}% + \setlength\pflabelwdv{\pflabelwdIII}% + \renewcommand\labelenumiii{\theenumiii.}% + \renewcommand{\p@enumiii}{}% + \or + \setlength\pflabelwdiv{\pflabelwdI}% + \setlength\pflabelwdv{\pflabelwdII}% + \renewcommand\labelenumiv{\theenumiv.}% + \renewcommand{\p@enumiv}{}% + \or + \setlength\pflabelwdv{\pflabelwdI}% + \renewcommand\labelenumv{\theenumv.}% + \renewcommand{\p@enumv}{}% + \fi} +% Modified from latex.ltx to make left-aligned numbers + \newenvironment{subpf}{% + \ifnum \@enumdepth >4\@toodeep\else + \advance\@enumdepth\@ne + \csname numpf@set\romannumeral\the\@enumdepth\endcsname + \edef\@enumctr{enum\romannumeral\the\@enumdepth}% + \expandafter + \list + \csname label\@enumctr\endcsname + {\usecounter\@enumctr\def\makelabel##1{\hss\rlap{##1}\hfill}}% + \fi}{\endlist} + \newenvironment{subpf*}{% + \ifnum \@enumdepth >4\@toodeep\else + \advance\@enumdepth\@ne + \csname numpf@set\romannumeral\the\@enumdepth @star\endcsname + \edef\@enumctr{enum\romannumeral\the\@enumdepth}% + \expandafter + \list + \csname label\@enumctr\endcsname + {\usecounter\@enumctr\def\makelabel##1{\hss\rlap{##1}\hfill}}% + \fi}{\endlist} + \newcommand{\linenum} + {\csname labelenum\romannumeral\the\@enumdepth\endcsname} + \newenvironment{pfarray} + {\pfln\numpf@rray} + {\endarray\end{math}\ignorespacesafterend} + \newcommand{\subpfalign@@set}{% + \advance\@enumdepth\@ne + \setcounter{enum\romannumeral\the\@enumdepth}{1}% + \let\numpf@amsmathLet@\Let@ + \def\Let@{\let\\\numpf@spf@lignlb}} +} + +% Here are the proof environments in math mode. +% The stem is ``pfalign''. +% Prefixing by ``sub'' indicates a new layer in the line numbering. +% Suffixing by ``ed'' specifies that the materials are not displayed. +% An asterisk used with ``sub'' specifies that +% the space-saving margins are to be used. +% One can play with the usual parameters to modify the spacing, e.g., +% \jot=0pt +% \abovedisplayskip=0pt +% \afterdisplayskip=0pt +% These have to be issued before the environment starts. +% Default overlay specifications in beamer do not apply to these commands. + +\def\numpf@mknum@norm#1{\makebox[\labelwidth][l]{#1}\hspace{\labelsep}} +\def\numpf@mknum@star#1% + {\hspace{\pfmargin}\hspace{-\labelsep}\hspace{-\labelwidth}% + \makebox[\labelwidth][l]{#1}\hspace{\labelsep}} + +\def\numpf@lign@mklbl{% + \edef\@currentlabel + {\csname p@enum\romannumeral\the\@enumdepth\endcsname + \csname theenum\romannumeral\the\@enumdepth\endcsname}% +% Adapted from \make@display@tag in amsmath.sty + \ifmeasuring@\else + \ifx\df@label\@empty\else + \@xp\ltx@label\@xp{\df@label}% + \global\let\df@label\@empty + \fi + \fi +} + +\newenvironment{subpfalign} + {\let\numpf@mknum\numpf@mknum@norm\collect@body\subpfalign@}{} +\newenvironment{subpfalign*} + {\let\numpf@mknum\numpf@mknum@star\collect@body\subpfalign@}{} +\newcommand{\subpfalign@}[1]{\bgroup + \ifnum \@enumdepth >4\@toodeep\else\subpfalign@@{#1}\fi +\egroup\ignorespaces} +\newcommand{\subpfalign@@}[1]{\subpfalign@@set + \def\numpf@spf@lignlb{\relax\iffalse{\fi\ifnum0=`}\fi + \@ifstar{\numpf@spf@lignlb@star}{\numpf@spf@lignlb@}}% + \begin{flalign*} +% Hopefully no one uses \Let@ except amsmath. + \global\let\Let@\numpf@amsmathLet@ + &\numpf@mknum{\linenum}% + \numpf@lign@mklbl + \end{flalign*}} +% The starred version has one fewer ampersand before the line break. +% Modified from amsmath.sty, especially \math@cr +\def\numpf@spf@lignlb@{% + \new@ifnextchar[\numpf@spf@lignlb@@{\numpf@spf@lignlb@@[\z@]}} +\def\numpf@spf@lignlb@@[#1]{\ifnum0=`{\fi \iffalse}\fi + &\numpf@lign@mklbl\math@cr@@@ + \noalign{\vskip#1\relax}% + \refstepcounter{enum\romannumeral\the\@enumdepth}% + &\numpf@mknum{\linenum}&} +\def\numpf@spf@lignlb@star{% + \new@ifnextchar[\numpf@spf@lignlb@@star{\numpf@spf@lignlb@@star[\z@]}} +\def\numpf@spf@lignlb@@star[#1]{\ifnum0=`{\fi \iffalse}\fi + \numpf@lign@mklbl\math@cr@@@ + \noalign{\vskip#1\relax}% + \refstepcounter{enum\romannumeral\the\@enumdepth}% + &\numpf@mknum{\linenum}&} + + +% This should store the current way to show the line number, +% wherever the command is. +% It should also step the counter. +% Currently, it only works for pfaligned. +\newcommand{\numpf@shownum}{} +\newcommand{\numpf@shownum@backup}{} +\newcommand{\skippfnum}{% + \global\let\numpf@shownum@backup\numpf@shownum + \global\def\numpf@shownum + {\global\let\numpf@shownum\numpf@shownum@backup}} + +% If needed, one can adjust \minalignsep before pfaligned, as in +% \renewcommand\minalignsep{4cm} +% \jot in pfaligned is by default can set to 0pt. +% To change it back (locally), use +% \pfalignedjot=\jot +% \label's must be put at the beginning of the lines. +\newlength{\pfalignedjot} +\setlength{\pfalignedjot}{0pt} +% The only difference between the beamer and the non-beamer versions +% is the overlay option. +\@ifclassloaded{beamer}{% + \newenvironment<>{pfaligned}[1] + {\def\numpf@pf@ligned@txt{#1}% + \def\numpf@pf@ligned@overlay{#2}% + \collect@body\pfaligned@@} + {\ignorespacesafterend} + \newcommand{\pfaligned@@}[1]{% + \let\numpf@amsmathLet@\Let@ + \def\Let@{\let\\\numpf@pf@lignedlb}% + \expandafter\onslide\numpf@pf@ligned@overlay{\pfln + \renewcommand{\numpf@shownum}{% + \refstepcounter{enum\romannumeral\the\@enumdepth}% + \hspace{-\labelwidth}\hspace{-\labelsep}% + \numpf@mknum@norm{\linenum}}% + \makebox[\linewidth][l]{\begin{math}\jot\pfalignedjot\begin{aligned}[t] + % Hopefully no one uses \Let@ except amsmath. + \global\let\Let@\numpf@amsmathLet@ + &\text{\numpf@pf@ligned@txt}% +  + \end{aligned}\end{math}}}\vspace{\pfalignedjot}} +}{% + \newenvironment{pfaligned}[1] + {\def\numpf@pf@ligned@txt{#1}% + \collect@body\pfaligned@@}{\ignorespacesafterend} + \newcommand{\pfaligned@@}[1]{% + \let\numpf@amsmathLet@\Let@ + \def\Let@{\let\\\numpf@pf@lignedlb}% + \pfln + \renewcommand{\numpf@shownum}{% + \refstepcounter{enum\romannumeral\the\@enumdepth}% + \hspace{-\labelwidth}\hspace{-\labelsep}% + \numpf@mknum@norm{\linenum}}% + \makebox[\linewidth][l]{\begin{math}\jot\pfalignedjot\begin{aligned}[t] + % Hopefully no one uses \Let@ except amsmath. + \global\let\Let@\numpf@amsmathLet@ + &\text{\numpf@pf@ligned@txt}% +  + \end{aligned}\end{math}}\vspace{\pfalignedjot}} +} +% The starred version has one fewer ampersand after the line break. +% Modified from amsmath.sty, especially \math@cr +\def\numpf@pf@lignedlb{\relax\iffalse{\fi\ifnum0=`}\fi + \@ifstar{\numpf@pf@lignedlb@star}{\numpf@pf@lignedlb@}} +\def\numpf@pf@lignedlb@{% + \new@ifnextchar[\numpf@pf@lignedlb@@{\numpf@pf@lignedlb@@[\z@]}} +\def\numpf@pf@lignedlb@@[#1]{\ifnum0=`{\fi \iffalse}\fi + \math@cr@@@ + \noalign{\vskip#1\relax}% + &\numpf@shownum&% + \edef\@currentlabel + {\csname p@enum\romannumeral\the\@enumdepth\endcsname + \csname theenum\romannumeral\the\@enumdepth\endcsname}} +\def\numpf@pf@lignedlb@star{% + \new@ifnextchar[\numpf@pf@lignedlb@@star{\numpf@pf@lignedlb@@star[\z@]}} +\def\numpf@pf@lignedlb@@star[#1]{\ifnum0=`{\fi \iffalse}\fi + \math@cr@@@ + \noalign{\vskip#1\relax}% + &\numpf@shownum% + \edef\@currentlabel + {\csname p@enum\romannumeral\the\@enumdepth\endcsname + \csname theenum\romannumeral\the\@enumdepth\endcsname}} + +% !!! dangerous bend !!! +% Partly from https://tex.stackexchange.com/a/541683 +% One left-aligned column is always added at the beginning and +% one right-aligned column is always added at the end. +% Best used with \extracolsep plus \stretch{} or \fill. +% To temporarily get rid of the added stretchable space, +% issue \extracolsep{0pt}. +\newcommand{\numpf@rray}[1]{% + \tabto{\CurrentLineWidth}% + \begin{math}\everymath={\displaystyle}% + \let\ltx@label\label + \let\label\numpf@rray@label + \setlength{\numpf@templen}{\linewidth}% + \addtolength{\numpf@templen}{-\TabPrevPos}% +% Modified from array and tabular* in latex.ltx + \setlength\dimen@{\numpf@templen}% + \let\@acol\@arrayacol + \let\@classz\@arrayclassz + \let\@classiv\@arrayclassiv + \let\\\numpf@rraylb + \edef\@halignto{to\the\dimen@}\@tabarray[t] + {@{}l@{\extracolsep{\fill}}#1@{\extracolsep{\fill}}r@{}}} +% The starred form removes the ampersand before the line break. +\def\numpf@rraylb{\relax\iffalse{\fi\ifnum0=`}\fi + \@ifstar{\numpf@rraylb@star}{\numpf@rraylb@}}% +\def\numpf@rraylb@{% + \new@ifnextchar[\numpf@rraylb@@{\numpf@rraylb@@[\z@]}% +} +\def\numpf@rraylb@@[#1]{\ifnum0=`{\fi \iffalse}\fi + &\@arraycr[#1]% + \refstepcounter{enum\romannumeral\the\@enumdepth}% + \hspace{-\labelwidth}\hspace{-\labelsep}% + \numpf@mknum@norm{\linenum}} +\def\numpf@rraylb@star{% + \new@ifnextchar[\numpf@rraylb@@star{\numpf@rraylb@@star[\z@]}% +} +\def\numpf@rraylb@@star[#1]{\ifnum0=`{\fi \iffalse}\fi + \@arraycr[#1]% + \refstepcounter{enum\romannumeral\the\@enumdepth}% + \hspace{-\labelwidth}\hspace{-\labelsep}% + \numpf@mknum@norm{\linenum}} +\def\numpf@rray@label#1{% + \edef\@currentlabel + {\csname p@enum\romannumeral\the\@enumdepth\endcsname + \csname theenum\romannumeral\the\@enumdepth\endcsname}% + \ltx@label{#1}} + +% You may find \popqed and \qedhere helpful. + +% To do +% - keyval list of options to control, say, spacing. +% - option to omit numbering for one line via \skippfnum +% for other environments +% - take care of itemize in addition to enumerate. +\endinput diff --git a/cheatsheets/cs1231s/cheatsheet.pdf b/cheatsheets/cs1231s/cheatsheet.pdf new file mode 100644 index 0000000..193b803 Binary files /dev/null and b/cheatsheets/cs1231s/cheatsheet.pdf differ diff --git a/cheatsheets/cs1231s/cheatsheet.tex b/cheatsheets/cs1231s/cheatsheet.tex new file mode 100644 index 0000000..c2f2e6a --- /dev/null +++ b/cheatsheets/cs1231s/cheatsheet.tex @@ -0,0 +1,1107 @@ +\documentclass[a4paper]{article} +\usepackage{amsmath} +\usepackage{amsthm} +\usepackage{amssymb} + + +\usepackage[T1]{fontenc} +\usepackage{textcomp} +\usepackage{url} +% \usepackage{subcaption} +\usepackage{emptypage} +% \usepackage{multicol} +\usepackage{cancel} +\usepackage{mathtools} + +\usepackage{lscape} +\usepackage{pdflscape} + +\usepackage{float} + + +\usepackage{xifthen} +\usepackage[skip=10pt]{parskip} + +\usepackage{comment} +\usepackage[margin=0.5in]{geometry} +\setlength{\parindent}{0pt} + +\usepackage{1231num} + +\theoremstyle{definition} +\newtheorem*{defn}{Defn} + +\newtheorem*{propos}{Proposition} + +\renewcommand{\qedsymbol}{} + +\newtheorem{innertheorem}{Theorem} +\newenvironment{theorem}[1] + {\renewcommand\theinnertheorem{#1}\innertheorem} + {\endinnertheorem} + + +\author{Yadunand Prem} + +\title{Midterms Cheatsheet} + +\begin{document} +\section{Tables} + +\begin{tabular} {|l|c|c|} + Commutative & $p \land q \equiv q \land p$ & $p \lor q \equiv q \lor p$\\ + Associative & $p \land q \land r \equiv (p \land q) \land r$&\\ + Distributive & $p \land (q \lor r) \equiv (p \land q) \lor (p \land r)$&$p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)$\\ + Identity & $p \land \text{true} \equiv p$ & $p \lor \text{false} \equiv p$\\ + Negation & $p \lor \sim p \equiv \text{true}$ & $p \land \sim p \equiv \text{false}$\\ + Double Negative & $\sim(\sim p) \equiv p$ & \\ + Idempotent & $p \lor p \equiv p$ & $p \land p \equiv p$\\ + Universal bound & $p \lor \text{true} \equiv \text{true}$ & $p \land \text{false} \equiv \text{false}$\\ + de Morgan's & $\sim(p \land q) \equiv \sim p \lor \sim q$ & $\sim(p \lor q) \equiv \sim p \land \sim q$\\ + Absorption & $p \lor (p \land q) \equiv p$ & $p \land (p \lor q) \equiv p$\\ + Implication & $p \Rightarrow q \equiv \sim p \lor q$ & $$\\ + $\sim$(Implication) & $\sim (p \Rightarrow q) \equiv p \land \sim q$ & \\ + \hline & & \\ + Modus Ponens &$p \implies q, p$& $q$ \\ + Modus Tollens &$p \implies q, \sim q$& $\sim p$ \\ + Generalization &$p$& $p \lor q$ \\ + Specialization &$p \land q$& $p$ \\ + Conjunction &$p, q$& $p \land q$ \\ + Elimination &$p \lor q, \sim q$& $p$ \\ + Transitivity &$p \implies q, q \implies r$& $p \implies r$ \\ + Division into cases &$p \land q, p \implies r, q \implies r$& $r$ \\ + Contradiction &$\sim p \implies \text{false}$& $p$ \\ + \hline & & \\ + Commutative & $A \cup B = B \cup A$ & \\ + Associative & $(A \cup B) \cup C = A \cup (B \cup C)$ & \\ + Distributive & $A \cup (B \cap C) = (A \cup B) \cap (A \cup C)$ & $A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$\\ + Identity & $A \cup \emptyset = A$ & $A \cap U = A$\\ + Complement & $A \cup \bar A = U$ & $A \cap \bar A = \emptyset$\\ + Double Complement & $\bar{\bar A} = A$ & \\ + Idempotent & $A \cup A = A$ & $A \cap A = A$\\ + Universal Bound & $A \cup U = U$ & $A \cap \emptyset = \emptyset$ \\ + De Morgan's & $\overline{A \cup B} = \bar{A} \cap \bar{B}$ & $\overline{A \cap B} = \bar{A} \cup \bar{B}$\\ + Absorption & $A \cup (A \cap B) = A$ & $A \cap (A \cup B) = A$\\ + Complements of U and $\emptyset$ & $\bar U =\emptyset$ & $\bar \emptyset = U$\\ + Set Difference & $A \setminus B = A \cap \bar B$ &\\ + \hline & & \\ + F1 Commutative & $a + b = b + a$ & $ab = ba$ \\ + F2 Associative & $(a + b)+c = a + (b + c)$ & $(ab)c = a(bc)$ \\ + F3 Distributive & $a(b+c) = ab + ac$ & $(b+c)a = ba + ca$ \\ + F4 Identity & $0 +a = a + 0 = a$ & $1 \cdot a = a \cdot 1 = a $ \\ + F5 Additive inverses & $a + (-a) = (-a) + a = 0$ & \\ + F6 Reciprocals & $a \cdot \frac{1}{a} = \frac{1}{a} \cdot a = 1$ & $a \not = 0$ \\ + \hline & & \\ + T1 Cancellation Add & $a + b = a + c$ & $b = c$ \\ + T2 Possibility of Sub & There is one $x, a + x = b$ & $x = b - a$ \\ + T3 & $b - a = b + (-a)$ & \\ + T4 & $-(-a) = a$ & \\ + T5 & $a(b-c)=ab-ac$ & \\ + T6 & $0 \cdot a = a \cdot 0 = 0$ & \\ + T7 Cancellation Mul & $ab = ac$ & $b = c, a \not = 0$ \\ + T8 Possibility of Div & $a \not = 0, ax = b$ & $x = \frac{b}{a}$ \\ + T9 & $a \not = 0, \frac{b}{a} = b \cdot a^{-1}$ & \\ + T10 & $a \not = 0, (a^{-1})^{-1} = a$ & \\ + T11 Zero Product& $ab = 0 \Rightarrow a = 0 \lor b = 0$ & \\ + T12 Mul with -ve & $(-a)b = a(-b) - -(ab)$ & $-\frac{a}{b} = \frac{-a}{b} = \frac{a}{-b}$\\ + T13 Equiv Frac & $\frac{a}{b} = \frac{ac}{bc}$ & $b \not = 0, c \not = 0$\\ + T14 Add Frac & $\frac{a}{b} + \frac{c}{d} = \frac{ad + bc}{bd}$ & $b \not = 0, d \not = 0$\\ + T15 Mul Frac & $\frac{a}{b} \cdot \frac{c}{d} = \frac{ac}{bd}$ & $b \not = 0, d \not = 0$\\ + T16 Div Frac & $\frac{\frac{a}{b}}{\frac{c}{d}} = \frac{ac}{bd}$ & $b \not = 0, d \not = 0$\\ +\end{tabular} + +\begin{tabular} {|l|c|c|} + \hline & & \\ + Ord1 & $\forall a,b \in \mathbb{R}^+$ & $a + b > 0, ab > 0$\\ + Ord2 & $\forall a,b \in \mathbb{R}_{\not = 0}$ & $a$ is positive or negative and not both\\ + Ord3 & 0 is not positive & \\ + $a < b$ & means $b + (-a)$ is positive & \\ + $a \leq b$ & means $a < b$ or $a = b$ & \\ + $a < 0$ & means a is negative& \\ + T17 Trichotomy Law & $a < b \lor b > a \lor a = b$ & \\ + T18 Transitive Law & $a < b$ and $b < c$ & $a < c$\\ + T19 & $a < b$ & $a + c < b + c$ \\ + T20 & $a < b$ and $c > 0$ & $ac < bc$ \\ + T21 & $a \not = 0$ & $a^2 > 0$ \\ + T22 & $1 > 0$ & \\ + T23 & $a < b$ and $c < 0$ & $ac > bc$ \\ + T24 & $a < b$ & $-a > -b$ \\ + T25 & $ab > 0$ & a and b are both positive or negative \\ + T26 & $a < c$ and $b < d$ & $a+b < c+d$ \\ + T27 & $0 < a < c$ and $<0 < b < d$ & $0 < ab < cd$ \\ +\end{tabular} + +\section{Math} + +\begin{defn}{Even and Odd Integers}\\ + n is even $\Leftrightarrow \exists$ an integer $k$ s.t. $n = 2k$\\ + n is odd $\Leftrightarrow \exists$ an integer $k$ s.t. $n = 2k + 1$ +\end{defn} + +\begin{defn}{Divisibility}\\ + $n$ and $d$ are integers and $d \not= 0$ \\ + $d | n \Leftrightarrow \exists k \in \mathbb{Z}$ s.t. $n = dk$ +\end{defn} + +\begin{theorem}{4.2.1} Every Integer is a rational number \end{theorem} + +\begin{theorem}{4.2.2} The sum of any two rational numbers is rational \end{theorem} + +\begin{theorem}{4.3.1} For all $a, b \in \mathbb{Z}^+$, if $a | b$, then $a \leq b$ \end{theorem} + +\begin{theorem}{4.3.2} Only divisors of $1$ are $1$ and $-1$ \end{theorem} + +\begin{theorem}{4.3.3} $\forall a, b, c \in \mathbb{Z}$ if $a | b$, $b | c$, $a | c$ \end{theorem} + +\begin{theorem}{4.6.1} There is no greatest integer \end{theorem} + +\begin{propos}{4.6.4} For all integers $n$, if $n^2$ is even, then $n$ is even. \end{propos} + +\begin{defn}{Rational} $r$ is rational $\Leftrightarrow \exists a, b \in \mathbb{Z}$ s.t. $r = \frac{a}{b}$ and $b \not=0$ \end{defn} + +\begin{defn}{Fraction in lowest term:} fraction $\frac{a}{b}$ is lowest term if largest $\mathbb{Z}$ that divies both $a$ and $b$ is 1 \end{defn} + +\begin{theorem}{4.7.1} $\sqrt{2}$ is irrational \end{theorem} + +\section{Logic of Combound Statements} + +\begin{theorem}{3.2.1} Negation of universal stmt $\sim(\forall x \in D, P(x)) \equiv \exists x \in D$ s.t. $\sim P(x)$ \end{theorem} + +\begin{theorem}{3.2.1} Negation of existential stmt $\sim(\exists x \in D$ s.t. $P(x)) \equiv \forall x \in D, \sim P(x)$ \end{theorem} + +\begin{defn}{Contrapositive} of $p \Rightarrow q \equiv \sim q \Rightarrow \sim p$ \end{defn} + +\begin{defn}{Converse} of $p \Rightarrow q$ is $q \Rightarrow p$ \end{defn} + +\begin{defn}{Inverse} of $p \Rightarrow q$ is $\sim p \Rightarrow \sim q$ \end{defn} + +\begin{defn}{Only if:} $p$ only if $q$ means $\sim q \Rightarrow \sim p \equiv p \Rightarrow q$ \end{defn} + +\begin{defn}{Biconditional:} $p \Leftrightarrow q \equiv (p \Rightarrow q) \land (q \Rightarrow p)$ \end{defn} + +\begin{defn} $r$ is sufficient condition for $s$ means if $r$ then $s$, $r \Rightarrow s$ \end{defn} + +\begin{defn} $r$ is necessary condition for $s$ means if $\sim r$ then $\sim s$, $s \Rightarrow r$ \end{defn} + +\begin{defn}{Proof by Contradiction}\\ If you can show that the supposition that sttatement $p$ is false leads to a contradiction, then you can conclude that $p$ is true \end{defn} + +\section{Methods of Proof} + +\begin{tabular} {|c|l|} + \hline + Statement & Proof Approach \\ + $\forall x \in D\ P(X)$ & Direct: Pick arbitrary x, prove P is true for that x. \\ + & Contradiction: Suppose not, i.e. $ \exists x(\sim p)$... Hence supposition $\sim p$ is false (P3) \\ + \hline + $\exists x \in D\ P(X)$ & Direct: Find x where P is true. \\ + & Contradiction: Suppose not, i.e. $\forall x (\sim p)$... Hence supposition $\sim p$ is false (P3) \\ + \hline + $P \Rightarrow Q$ & Direct: Assume P is true, prove Q \\ + & Contradiction: Assume P is true and Q is false, then derive contradiction \\ + & Contrapositive: Assume $\sim Q$, then prove $\sim P$ \\ + \hline + $P \Leftrightarrow Q$ & Prove both $P \Rightarrow Q$ and $Q \Rightarrow P$ \\ + \hline + $xRy$. Prove R is equivalence & Prove Reflexive, Symmetric and Transitive \\ + \hline + Reflexive & \\ + \hline + Symmetric & \\ + \hline + Antisymmetric & \\ + \hline + Transitive & \\ + \hline + + +\end{tabular} + +\begin{defn}{Proof by Contraposition}\\ + 1. Statement to be proved $\forall x \in D\ (P(x) \Rightarrow Q(x))$\\ + 2. Contrapositive Form: $\forall x \in D\ (\sim Q(x) \Rightarrow \sim P(x))$\\ + 3. Prove by direct proof\\ + 3.1 Suppose x is an element of D s.t. $Q(X)$ is false\\ + 3.2 Show that P(x) is false.\\ + 4. Therefore, original statement is true +\end{defn} + + +\section{Set Theory} + +\begin{defn}{Set: Unordered collection of objects}\\ Order and duplicates don't matter \end{defn} + +\begin{defn}{Membership of Set $\in$: } If $S$ is set, $x \in S$ means $x$ is an element of $S$ \end{defn} + +\begin{defn}{Cardinality of Set $|S|$: } The number of elements in $S$ \end{defn} + +Common Sets: + +$\mathbb{N}$ - Natural Numbers, $\{0, 1, 2\}$ + +$\mathbb{Z}$ - Integers + +$\mathbb{Q}$ - Rational + +$\mathbb{R}$ - Real + +$\mathbb{C}$ - Complex + +$\mathbb{Z}^\pm$ - Positive/Negative Integers + +\begin{defn}{Subset} + $A \subseteq B \Leftrightarrow$ Every element of $A$ is also an element of $B$\\ + $A \subseteq B \Leftrightarrow \forall x(x\in A \Rightarrow x \in B)$ +\end{defn} + +\begin{defn}{Proper Subset} $A \subsetneq B \Leftrightarrow (A \subseteq B \land A \not = B)$ \end{defn} + +\begin{theorem}{6.2.4} An empty set is a subset of every set, i.e. $\emptyset \subseteq A$ for all sets $A$ \end{theorem} + +\begin{defn}{Cartesian Product} $A \times B = \{(a, b): a \in A \land b \in B\} $ \end{defn} + +\begin{defn}{Set Equality} + $A = B \Leftrightarrow A \subseteq B \land B \subseteq A$ \\ + $A = B \Leftrightarrow \forall x (x \in A \Leftrightarrow x \in B)$ +\end{defn} + +\begin{defn}{Union:} $A \cup B = \{x \in U: x \in A \lor x \in B\}$ \end{defn} + +\begin{defn}{Intersection:} $A \cap B = \{x \in U: x \in A \land x \in B\}$ \end{defn} + +\begin{defn}{Difference:} $B \setminus A = \{x \in U: x \in B \land x \not\in A\}$ \end{defn} + +\begin{defn}{Disjoint:} $A \cap B = \emptyset$ \end{defn} + +\begin{theorem}{4.4.1} Quotient-Remainder + $n \in \mathbb{Z}, d \in \mathbb{Z}^+$\\ there exists unique integers q and r such that $n = dq + r$ and $0 \leq r < d$ +\end{theorem} + +\begin{defn}{Power Set:} The set of all subsets of $A$, has $2^n$ elements. \end{defn} + +\begin{theorem}{6.3.1} + Suppose $A$ is a finite set with $n$ elements, then $P(A)$ has $2^n$ elements. + $|P(A)| = 2^{|n|}$ +\end{theorem} + +\begin{defn}{Cartesian Product of $A_n$} + $= A_1 \times A_2 \times ... \times A_n = \{(a_1, a_2,...a_n): a_1 \in A_1 \land a_2 \in A_2...$ +\end{defn} + +\begin{theorem}{6.2.1} Subset Relations + \begin{numpf*} + \pfln Inclusion of Intersection: $A \cap B \subseteq A, A \cap B \subseteq B$ + \pfln Inclusion in Union $A \subseteq A \cup B, B \subseteq A \cup B$ + \pfln Transitive Property of Substs: $A \subseteq B \land B \subseteq C \Rightarrow A \subseteq C$ + \end{numpf*} +\end{theorem} + +\section{Relations} + +\begin{defn} Relation from A to B is a subset of $A \times B$\\ + Given an ordered pair$(x, y) \in A\times B$, $x$ is + related to y by $R$ is written $xRy \Leftrightarrow (x, y) \in R$ +\end{defn} + +\begin{defn} Domain, Co-domain, Range\\ + Let $A$ and $B$ be sets and $R$ be a relation from $A$ to $B$ + \begin{numpf*} + \pfln Domain of R: is set $\{a \in A: aRb$ for some $b \in B\}$ + \pfln Codomain of R: Set B + \pfln Range of R: is set $\{b \in B: aRb$ for some $a \in A\}$ + \end{numpf*} +\end{defn} + +\begin{defn} Inverse Relation\\ + Let $R$ be a relation from $A$ to $B$, + $R^{-1} = \{(y, x) \in B\times A: (x, y) \in R\}$\\ + $\forall x \in A, \forall y \in B ((y, x) \in R^{-1} \Leftrightarrow (x, y) \in R)$ +\end{defn} + +\begin{defn} + Relation on a Set $A$ is a relation from $A$ to $A$. +\end{defn} + +\begin{defn} Composition of Relations\\ + A, B and C be sets. $R \subseteq A \times B$ be a relation. $S \subset B \times C$ be relation. Composition of R with S, denoted $S \circ R$ is relation from A to C such that: \\ + $\forall x \in A, \forall z \in C(x S \circ R z \Leftrightarrow (\exists y \in B (xRy \land ySz)))$ +\end{defn} + +\begin{propos} Composition is Associative + $A, B, C, D$ be sets. $R \subseteq A \times B$, $S \subseteq B \times C$, $T \subseteq C \times D$\\ + $T \circ ( S \circ R) = T \circ S \circ R$ +\end{propos} + +\begin{propos} Inverse of Composition + $A, B, C$ be sets. $R \subseteq A \times B$, $S \subseteq B \times C$\\ + $(S \circ R)^{-1} = R^{-1} \circ S^{-1}$ +\end{propos} + +\begin{defn} \textbf{Reflexivity, Symmetry, Transitivity} + \begin{numpf*} + \pfln Reflexivity: $\forall x \in A (xRx)$ + \pfln Symmetry: $\forall x,y \in A (xRy \Rightarrow yRx)$ + \pfln Transitivity:$\forall x,y,z \in A (xRy \land yRz \Rightarrow xRz)$ + \end{numpf*} + Refer to proof 6 +\end{defn} + +\begin{defn} Transitive Closure\\ + Transitive closure of R is relation $R^t$ on A that satiesfies + \begin{numpf*} + \pfln $R^t$ is transitive + \pfln $R \subseteq R^t$ + \pfln If $S$ is any other transitive relation that contains $R$, then $R^t \subseteq S$ + \end{numpf*} +\end{defn} + +\begin{defn} Partition\\ + $P$ is partition of set A if + \begin{numpf*} + \pfln $P$ is a set of which all elements are non empty subsets of A, $\emptyset \not = S \subseteq A$ for all $S \in P$ + \pfln Every element of $A$ is in exactly on element of P, \\ + $\forall x \in A\ \exists S \in P (x \in S)$ and \\ + $\forall x \in A\ \exists S_1, S_2 \in P(x \in S_1 \land x \in S_2 \Rightarrow S_1 = S_2)$ + \end{numpf*} + OR $\forall x \in A\ \exists!S \in P(x \in S)$\\ + Elements of a partition are called components +\end{defn} + +\begin{defn} Relation Induced by a partition\\ + Given partition $P$ of $A$, the relation $R$ induced by partition: \\ + $\forall x, y \in A, xRy \Rightarrow \exists$ a component of $S$ of $P$ s.t. $x, y \in S$ +\end{defn} + +\begin{theorem}{8.3.1}[Relation Induced by a Partition] + Let $A$ be a set with a partition and let R be a relation induced by the partition. Then $R$ is reflexive, symmetric and transitive +\end{theorem} + +\begin{defn}[Equivalence Relation] + $A$ be set and $R$ be relation. $R$ is equivalence relation iff $R$ is reflexive, symmetric and transitive +\end{defn} + +\begin{defn} Equivalence Class\\ + Suppose $A$ is set and $\sim$ is equivalence relation on A. For each $A \in A$, equivalence class of $a$, denoted $[a]$ and called class of $a$ is set of all elements $x \in A$ s.t. $a\sim x$\\ + $[a]_{\sim} = \{x \in A: a \sim x \}$ +\end{defn} + +\begin{theorem}{8.3.4} The partition induced by an Equivalence Relation\\ + If $A$ is a set and $R$ is an equivalence relation on $A$, then distinct equivalence classes of $R$ form a partition of $A$; that is, the union of the equivalence classes is all of $A$, and the intersection of any 2 disctinct classes is empty. +\end{theorem} + +\begin{defn} Congruence\\ + Let $a, b \in \mathbb{Z}$ and $n \in \mathbb{Z}^+$. Then $a$ is congruent to $b$ modulo $n$ iff $a - b = nk$, for some $k \in \mathbb{Z}$. In other words, $n | (a - b)$. We write $a \equiv b (\text{mod}\ n)$ +\end{defn} + +\begin{defn} Set of equivalence classes\\ + Let $A$ be set and $\sim$ be an equivalence relation on $A$. Denote by $A/\sim$, the set of all equivalence classes with respect to $\sim$, i.e. + + $A/\sim = \{[x]_\sim: x \in A\}$ +\end{defn} + +\begin{theorem}{Equivalence Classes} form a partition + Let $\sim$ be an equiv. relation on $A$. Then $A/\sim$ is a partition of A. +\end{theorem} + +\begin{defn}[Antisymmetry] + $R$ is antisymmetric iff $\forall x, y \in A(xRy \land yRx \Rightarrow x = y)$ \textit{(DOES NOT IMPLY NOT SYMMETRIC)} +\end{defn} + +\begin{defn}[Partial Order Relation] + $R$ is Partial Order iff R is \textit{reflexive}, \textit{antisymmetric} and \textit{transitive}. +\end{defn} + +\begin{defn}{Partially Ordered Set} + Set A is called poset with respect to partial order relation $R$ on $A$, denoted by $(A, R)$ (Proof 7) +\end{defn} + +\begin{defn}{$x \preccurlyeq y$} + is used as a general partial order relation notation +\end{defn} + +\begin{defn}[Hasse Diagram] + Let $\preccurlyeq$ be a partial order on set $A$. Hasse diagram satisfies the following condition for all distinct $x, y, m \in A$ \\ + If $x \preccurlyeq y$ and no $m \in A$ is s.t. $x \preccurlyeq m \preccurlyeq y$, then x is placed below y with a line joining them, else no line joins $x$ and $y$. +\end{defn} + +\begin{defn}[Comparability] + $a, b \in A$ are comparable iff $a \preccurlyeq b$ or $b \preccurlyeq a$. Otherwise, they are \textbf{noncomparable} +\end{defn} + +\begin{defn}[Maximal, Minimal, Largest Smallest] + Set $A$ be partially ordered w.r.t. a relation $\preccurlyeq$ and $c \in A$ + \begin{numpf} + \pfln c is maximal element of $A$ iff $\forall x \in A$, either $x \preccurlyeq c$ or $x$ and $c$ are non-comparable. OR $\forall x in A(c \preccurlyeq x \Rightarrow c = x)$ + \pfln c is minimal element of $A$ iff $\forall x \in A$, either $c \preccurlyeq x$ or $x$ and $c$ are non-comparable. OR $\forall x in A(x \preccurlyeq c \Rightarrow c = x)$ + \pfln c is largest element of $A$ iff $\forall x \in A (x \preccurlyeq c)$ + \pfln c is smallest element of $A$ iff $\forall x \in A (c \preccurlyeq x)$ + \end{numpf} +\end{defn} + +\begin{propos} A smallest element is minimal\\ + Consider a partial order $\preccurlyeq$ on set $A$. Any smallest element is minimal. + \begin{numpf} + \pfln Let $c$ be smallest elemnt + \pfln Take any $x \in A$ s.t. $x \preccurlyeq c$ + \pfln By smallestness, we know $c \preccurlyeq x$ too. + \pfln So $c = x$ by antisymmetry + \end{numpf} +\end{propos} + +\begin{defn}[Total Order Relations] All elements of the set are comparable\\ + R is total order iff $R$ is a partial order and $\forall x, y \in A (xRy \lor yRx)$ +\end{defn} + +\begin{defn}[Linearization of a partial order] + Let $\preccurlyeq$ be a partial order on set $A$. A linearization of $\preccurlyeq$ is a total order $\preccurlyeq *$ on $A$ s.t. $\forall x, y \in A (x \preccurlyeq y \Rightarrow x \preccurlyeq *\ y)$ +\end{defn} + +\begin{defn}[Kahn's Algorithm] + Input: A finite set $A$ and partial order $\preccurlyeq$ on $A$ + \begin{numpf} + \pfln Set $A_0 := A$ and $i := 0$ + \pfln Repeat until $A_i = \emptyset$ + \begin{subpf} + \pfln Find minimal element $c_i$ of $A_i$ wrt $\preccurlyeq$ + \pfln Set $A_{i+1} = A_i \setminus {c_i}$ + \pfln Set $i = i+1$ + \end{subpf} + \end{numpf} + + Output: A linearization $\preccurlyeq *$ of $\preccurlyeq$ defined by setting, for all indicies $i, j$\\ $c_i \preccurlyeq*\ c_j \Leftrightarrow i \leq j$ +\end{defn} + +\begin{defn}[Well ordered set] Let $\preccurlyeq$ be a total order on set $A$. $A$ is well ordered iff every nonempty subset of A contains a smallest element. OR\\ + $\forall S \in P(A), S \not = \emptyset \Rightarrow (\exists x \in S \forall y \in S (x \preccurlyeq y))$ E.g. $(\mathbb{N}, \leq)$ is well ordered but $(\mathbb{Z}, \leq)$ is not as there is no smallest integer (Theorem 4.6.1) + +\end{defn} + +\section{Proofs} + +\begin{proof} [\proofname\ L1S28] +Prove that the product of two consecutive odd numbers is always odd. +\begin{numpf*} + \pfln Let $a$ and $b$ be two consecutive odd numbers + \begin{subpf*} + \pfln Without loss of generality, assume that $a < b$, hence $b = a + 2$ + \pfln Now, $a = 2k+1$ (by defn of odd numbers) + \pfln Similarly, $b = a + 2 = 2k + 3$ + \pfln Therefore, $ab = (2k+1)(2k+3) = (4k^2 + 6k) + (2k + 3) = 4k^2 + 8k + 3 = 2(2k^2 + 4k + 1) + 1$ (by Basic Algebra) + \pfln Let $m = (2k^2 + 4k + 1)$ which is an integer (by closure of integers under $\times$ and $+$) + \pfln Then $ab = 2m + 1$ which is odd (by defn of odd numbers) + \end{subpf*} + \pfln Therefore, the product of two consecutive odd numbers is always odd. +\end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ L4S16] Sum of 2 even $\mathbb{Z}$ is even + \begin{numpf*} + \pfln Let m and n be two particular but arbitrarily chosen even intergers + \begin{subpf*} + \pfln Then $m = 2r$ and $n = 2s$ for some $\mathbb{Z}$ $r$ and $s$ (by defn of even number) + \pfln $m + n = 2r + 2s = 2(r+s)$ (by basic algebra) + \pfln 2(r+s) is an integer(closure of int under $\times$ and $+$) and an even number (by defn of even number) + \pfln Hence $m+n$ is an even number + \end{subpf*} + \pfln Therefore sum of any two even integers is even + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T 4.6.1] There is no greatest integer (Contradiction) + \begin{numpf*} + \pfln Suppose not, i.e. there is a greatest intger + \begin{subpf*} + \pfln Lets call this greatest integer g, and $g \geq n$ for all integers n + \pfln Let $G = g + 1$ + \pfln Now, $G$ is an integer (closure of integers under $+$) and $G > g$ + \pfln Hence, g is not the greatest integer, contradicting 1.1 + \end{subpf*} + \pfln Hence, the supposition that there is a greatest integer is false. + \pfln Therefore there is no greatest integer + \end{numpf*} +\end{proof} +\begin{proof}[\proofname\ L5S19] L5S19 Two sets are equal + \begin{numpf*} + \pfln Let sets $X$ and $Y$ be given. To prove $X$ = $Y$ + \pfln ($\subseteq$) Prove $X \subseteq Y$ + \pfln ($\supseteq$) Prove $X \supseteq Y$ + \pfln From (2) and (3), we can conclude that $X = Y$ + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ L5S22] L5S22 $\{x \in Z: x^2 = 1\} = \{1, -1\}$ + \begin{numpf*} + \pfln $\rightarrow$ + \begin{subpf*} + \pfln Take any $z \in \{x \in \mathbb{Z} : x^2 = 1\}$ + \pfln Then $z \in \mathbb{Z}$ and $z^2 = 1$ + \pfln So, $z^2 -1 = (z-1)(z+1) = 0$ (by basic algebra) + \pfln $\therefore$ $z-1 = 0$ or $z +1 = 0$ + \pfln $\therefore$ $z = 1$ or $z = -1$ + \pfln So, $z \in \{1, -1\}$ + \end{subpf*} + \pfln $\leftarrow$ + \begin{subpf*} + \pfln Take any $z \in \{1, -1\}$ + \pfln Then $z = 1$ or $z=-1$ + \pfln In either case, we have $z \in \mathbb{Z}$ and $z^2 = 1$ + \pfln So, $z \in \{x \in \mathbb{Z} : x^2 = 1\}$ + \end{subpf*} + \pfln Therefore, $\{x \in Z: x^2 = 1\} = \{1, -1\}$ (from (1) and (2)) + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ L6S27] $\forall x,y \in \mathbb{Z} (xRy \Leftrightarrow 3 | (x-y))$ is reflexive, symmetric, transitive + \begin{numpf*} + \pfln Proof of Reflexivity + \begin{subpf*} + \pfln Let $a$ be an arbitrarily chosen integer. + \pfln Now $a - a = 0$ + \pfln $3 | 0 $(since $ 0 = 3 \cdot 0)$, hence $3 |(a - a)$ + \pfln Therefore $aRa$ (by defn of R) + \end{subpf*} + \pfln Proof of Symmetry + \begin{subpf*} + \pfln Let a, b be arbitrarily chosen integers + \pfln Then $3|(a-b)$ (by defn of R), hence $a-b = 3k$ for some integer k (by defn of divisibility) + \pfln Multiplying both sides by $-1$ gives $b-a = 3(-k)$ + \pfln Since $-k$ is an integer, $3 | (b-a)$ (by defn of divisibility) + \pfln Therefore, $aRb \Rightarrow bRa$ (by defn of R) + \end{subpf*} + \pfln Proof of Transitivity + \begin{subpf*} + \pfln Let a, b, c be arbitrarily chosen integers + \pfln Then, $3 | (a - b)$ and $3 | (b - c)$ (by defn of R), hence $a-b = 3r$ and $b-c = 3s$ (by defn of divisiblity) + \pfln Adding both equations gives $a - c = 3r + 3s$ + \pfln Since $r+s$ is an integer, $3 | (a - c)$ (by defn of divisiblity) + \pfln Therefore $aRb \land bRc \Rightarrow aRc$ (by defn of R) + \end{subpf*} + \end{numpf*} +\end{proof} + +\begin{proof}[Lemma Rel.1 Equivalence Class L6S47] Let $\sim$ be an equivalence relation on $A$. The following are equivalent for all $x, y \in A$ (i) $x\sim y$, (ii) $[x] = [y]$, (iii) $[x] \cap [y] \not = \emptyset$ + \begin{numpf*} + \pfln $x \sim y \Rightarrow [x] = [y]$ + \begin{subpf*} + \pfln Suppose $x \sim y$ + \pfln Then $y \sim x$ (by symmetry) + \pfln For every $z \in [x]$ + \begin{subpf*} + \pfln $x \sim z$ (by defn of x) + \pfln $\therefore y \sim z$ (by transitivity of $y\sim x$) + \pfln $\therefore z \in [y]$ (by defn of $[y]$) + \end{subpf*} + \pfln This shows $[x] \subseteq [y]$ + \pfln Switching roles of $x$ and $y$, we can also see that $[y] \subseteq [x]$ + \pfln Therefore, $[x] = [y]$ + \end{subpf*} + \pfln $[x] = [y] \Rightarrow [x] \cap [y] \not = \emptyset$ + \begin{subpf*} + \pfln Suppose $[x] = [y]$ + \pfln Then $[x] \cap [y] = [x]$ (by idempotent law for $\cap$) + \pfln However, we know $x\sim x$ (by reflexivity of $\sim$) + \pfln This shows $x \in [x] = [x] \cap [y]$ (by defn of [x] and (2.2)) + \pfln Therefore $[x] \cap [y] \not = \emptyset$ + \end{subpf*} + \pfln $[x] \cap [y] \not = \emptyset \Rightarrow x \sim y$ + \begin{subpf*} + \pfln Suppose $[x] \cap [y] \not = \emptyset$ + \pfln Take $z \in [x] \cap [y]$ + \pfln Then $z \in [x]$ and $z \in [y]$ (by defn of $\cap$) + \pfln Then $x \sim z$ and $y \sim z$ (by defn of $[x]$ and $[y]$) + \pfln $y \sim z$ implies $z \sim y$ (by defn of symmetry) + \pfln Therefore, $x \sim y$ (by transitivity) + \end{subpf*} + \end{numpf*} +\end{proof} + +\begin{proof}[Proposition L6S54] Congruence-mod $n$ is an equivalence relation on $\mathbb{Z}$ for every $n \in \mathbb{Z}^+$ + \begin{numpf*} + \pfln (Reflexivity) For all $a \in \mathbb{Z}$ + \begin{subpf*} + \pfln $a - a = 0 = n \times 0$ + \pfln So $a \equiv a (\text{mod}\ n)$ (by defn of congruence) + \end{subpf*} + \pfln (Symmetry) + \begin{subpf*} + \pfln Let $a, b \in \mathbb{Z}$ s.t. $a \equiv a (\text{mod}\ n)$ + \pfln Then there is a $k \in \mathbb{Z}$ s.t. $a - b = nk$ + \pfln Then $b - a = -(a - b) = -nk = n(-k)$ + \pfln $-k \in \mathbb{Z}$ (by closure of integers under $\times$), so $b \equiv a (\text{mod}\ n)$ (by defn of congruence) + \end{subpf*} + \pfln (Transitivity) + \begin{subpf*} + \pfln Let $a, b,c \in \mathbb{Z}$ s.t. $a \equiv a (\text{mod}\ n)$ and $b \equiv c (\text{mod}\ n)$ + \pfln Then there is a $k,l \in \mathbb{Z}$ s.t. $a - b = nk$ and $b - c = nl$ + \pfln Then $a - c = (a - b) + (b - c) = nk + nl = n(k + 1)$ + \pfln $k + l \in \mathbb{Z}$ (by closure of integers under $+$), so $a \equiv c (\text{mod}\ n)$ (by defn of congruence) + \end{subpf*} + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ L6S69] $\forall a, b \in \mathbb{Z}^+, \forall a | b \Leftrightarrow b = ka$ for some integer $k$. Prove $|$ is a partial order relation on $A$ + \begin{numpf*} + \pfln $|$ is reflexive: Suppose $a \in A$. Then $a = 1 \dot a$, so $a|a$ (by defn of divisiblity) + \pfln $|$ is antisymmetric + \begin{subpf*} + \pfln Suppose $a, b \in \mathbb{Z}^+$ such that $aRb$ and $bRa$ + \pfln Then $b = ra$ and $a = sb$ for some integers $r$ and $s$ (by defn of divides). It follows that $b = ra = r(sb)$ + \pfln Dividing both sides by $b$ gives $1 = rs$ + \pfln Only product of two positive integers that equals 1 is $1 \dot 1$. + \pfln Thus $r = s = 1$, and so $a = sb = 1 \dot b = b$ + \pfln Therefore, $|$ is antisymmetric + \end{subpf*} + OR + \begin{subpf*} + \pfln Suppose $a, b \in \mathbb{Z}^+$ such that $a|b$ and $b|a$ + \pfln then $a \leq b$ and $b \leq a$ (by theorem 4.3.1) + \pfln So $a = b$ + \end{subpf*} + \pfln $|$ is transitive: Show that $\forall a, b, c \in A, a|b \land b|c \Rightarrow a |c)$ (theorem 4.3.3) + \end{numpf*} + +\end{proof} + + +\begin{proof}[\proofname\ T01Q9] The product of any two odd integers is an odd integer + \begin{numpf*} + \pfln Take any 2 odd numbers $a$ and $b$ + \pfln Then $a = 2k+1$ and $b = 2p + 1$ for $k,p \in Z$ (by defn of odd number) + \pfln Then $a\cdot b = (2k+1)(2p+1) = (4kp + 2k) + (2p + 1) = 2(2kp + p + k) +1$ (by defn of odd number) + \pfln Let $q = 2kp + p +k$ which is an integer (by closure of int under $+$ and $\times$ + \pfln Then nm = 2q + 1 which is odd (by defn of odd numbers) + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T01Q10] Let $n$ be an integer. Then $n^2$ is odd iff $n$ is odd + \begin{numpf*} + \pfln Proof By Contraposition, that is "if n is even, $n^2$ is even $(\Rightarrow)$ + \begin{subpf*} + \pfln Suppose $n$ is even. + \pfln Then $\exists k \in \mathbb{Z}$ s.t. $n = 2k$ (by defn of even integers) + \pfln $n^2 = (2k)^2 = 4k^2 = 2(2k^2)$ + \pfln Hence, $n^2$ = 2p, where $p = 2k^2 \in \mathbb{Z}$ (by closure of integers under $\times$) + \pfln Therefore, $n^2$ is even and this proves that if $n^2$ is odd, $n$ is odd. + \end{subpf*} + \pfln If $n$ is odd, then $n \times n = n^2$ is odd (T01Q9) + \pfln Therefore $n^2$ is odd if and only if $n$ is odd. + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T02Q3] Rational numbers are closed under addition + \begin{numpf*} + \pfln Let r and s be rational numbers + \pfln $\exists a,b,c,d \in \mathbb{Z}$ s.t. $r =\frac{a}{b}, s = \frac{c}{d}$ and $b \not = 0, d \not = 0$ (by defn of rational numbers) + \pfln Hence $r + s = \frac{a}{b} + \frac{c}{d} = \frac{ad + bc}{bd}$ (by basic algebra) + \pfln $ad + bd \in Z$ and $bd \in Z$ (closure of integers under $+$ and $\times$) + \pfln $bd \not = 0$ since $b \not = 0, d \not = 0$ + \pfln Hence $r+s$ is rational, therefore rational numbers are closed under addition + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T02Q10] if $n$ is a product of 2 positive integers $a$ and $b$, then $a \leq n^{1/2}$ or $b \leq n^{1/2}$ + \begin{numpf*} + \pfln Proof by contraposition, that is if $a > n^{1/2}$ and $b > n^{1/2}$, then $n$ is not a product of $a$ and $b$ + \pfln Suppose $a > n^{1/2}$ and $b > n^{1/2}$, then $ab > n^{1/2} \cdot n^{1/2} = n$ (by Appendix A T27) + \pfln Since $ab \not = n$, the contrapositive statement is true + \end{numpf*} + or by contradiction + \begin{numpf*} + \pfln Proof by contradiction, that is $n = ab$ and $a > n^{1/2}$ and $b > n^{1/2}$ + \pfln Since $a > n^{1/2}$ and $b > n^{1/2}$, then $ab > n^{1/2} \cdot n^{1/2} = n$ (by Appendix A T27) + \pfln This contradicts $n = ab$. Therefore original statement is true + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T03Q04] Let $A = \{2n+1: n \in \mathbb{Z}\}$ and $B = \{2n-5: n \in \mathbb{Z}\}$. Is $A$ = $B$? + \begin{numpf*} + \pfln $\subseteq$ + \begin{subpf} + \pfln Let $a \in A$, and $a = 2n + 1, n \in \mathbb{Z}$ + \pfln Then $a = 2n + 1 = 2 (n+3) - 5$ + \pfln $n + 3 \in Z$ (by closure of int under $+$) + \pfln Therefore, $a \in B$ (by defn of B) + \end{subpf} + \pfln $\supseteq$ + \begin{subpf} + \pfln Let $b \in A$, and $b = 2n - 5, n \in \mathbb{Z}$ + \pfln Then $b = 2n - 5 = 2 (n-3) + 1$ + \pfln $n - 3 \in Z$ (by closure of int under $-$) + \pfln Therefore, $b \in A$ (by defn of B) + \end{subpf} + \pfln Therefore, A = B + \end{numpf*} +\end{proof} +\begin{proof}[\proofname\ T03Q05] Prove $\forall A, B, C, A \cap (B \setminus C) = (A \cap B) \setminus C$ + \begin{numpf*} + \pfln $A \cap (B \setminus C) = \{x: x \in A \land x \in (B \setminus C) \}$ (by defn of $\cap$) + \pfln $ = \{x: x \in A \land (x \in B \land x \not \in C) \}$ (by defn of $\setminus$) + \pfln $ = \{x: x \in (A \land x \in B) \land x \not \in C \}$ (by associativity of $\land$) + \pfln $ = \{x: x \in (A \cap B) \land x \not \in C \}$ (by defn of $\cap$) + \pfln $ = \{x: x \in (A \cap B) \setminus C$ (by defn of $\setminus$) + \end{numpf*} +\end{proof} +\begin{proof}[\proofname\ T03Q05] Prove $\forall A, B, C, A \cap (B \setminus C) = (A \cap B) \setminus C$ + \begin{numpf*} + \pfln $A \cap (B \setminus C) = \{x: x \in A \land x \in (B \setminus C) \}$ (by defn of $\cap$) + \pfln $ = \{x: x \in A \land (x \in B \land x \not \in C) \}$ (by defn of $\setminus$) + \pfln $ = \{x: x \in (A \land x \in B) \land x \not \in C \}$ (by associativity of $\land$) + \pfln $ = \{x: x \in (A \cap B) \land x \not \in C \}$ (by defn of $\cap$) + \pfln $ = \{x: x \in (A \cap B) \setminus C$ (by defn of $\setminus$) + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname T03Q8] Let $A$ and $B$ be set. Show that $A \subseteq B$ if and only if $A \cup B = B$\\ + To show $A \cup B = B$, we need to show $A \cup B \subseteq B$ and $B \subseteq A \cup B$ + \begin{numpf*} + \pfln $\implies$ + \begin{subpf} + \pfln Suppose $A \subseteq B$ + \pfln (Show $A \cup B \subseteq B$) + \begin{subpf} + \pfln Let $z \in A \cup B$ + \pfln Then $z \in A$ or $z \in B$ (by defn of $\cup$) + \pfln Case 1: Suppose $z \in A$, then $Z \in B$ as $A \subseteq B$ line (1.1) + \pfln Case 2: Suppose $z \in B$, then $z \in B$. We have $z\in B$ in either case + \end{subpf} + \pfln (Show $A \cup B \supseteq B$) + \begin{subpf} + \pfln Let $z \in B$ + \pfln Then $z \in A$ or $z \in B$ (by generalization) + \pfln So $z \in A \cup B$ (by defn of $\cup$) + \end{subpf} + \pfln Therefore $A \cup B = B$ + \end{subpf} + \pfln $\impliedby$ + \begin{subpf} + \pfln Suppose $A \cup B = B$ + \pfln Let $z \in A$ + \begin{subpf} + \pfln Then $z \in A$ or $z \in B$ (by generalization) + \pfln So $z \in A \cup B$ (by defn of $\cup$) + \pfln So $z \in B$ since $A \cup B = B$ (2.1) + \end{subpf} + \pfln Therefore $A \subseteq B$ + \end{subpf} + \pfln Therefore, $A \subseteq B$ if and only iff $A \cup B = B$ + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T04Q05] Relation $S = \{(m,n) \in \mathbb{Z}^2: m^3 + n^3 \text{is even} \}$, Proof $S \circ S = S$ + \begin{numpf*} + \pfln ($\subseteq$) Suppose $(x, z) \in S \circ S$ + \begin{subpf} + \pfln Then $(x, y) \in S$ and $(y, z) \in S$ for some $y \in Z$ (defn of composition of relations) + \pfln So $x^3 + y^3$ is even and $y^3 + z^3$ is even + \pfln This implies that $x^3 + 2y^3 + z^3$ is even + \pfln This implies that $x^3 + z^3$ is even as $2y^3$ is even + \pfln Therefore, $(x, z) \in S$ (by defn of $S$) + \end{subpf} + \pfln ($\supseteq$) Suppose $(x,z) \in S$ + \begin{subpf} + \pfln Then $x^3 + z^3$ is even (by defn of S) + \pfln Case 1: $x^3$ is odd. + \begin{subpf} + \pfln Then $z^3$ is also odd. + \pfln This implies that $x^3 + 1^3$ is even and $1^3 + z^3$ is even + \pfln Thus, $(x,1) \in S$ and $(1,z) \in S$ (by defn of S) + \pfln So, $(x,z) \in S \circ S$ + \end{subpf} + \pfln Case 2: $x^3$ is even. + \begin{subpf} + \pfln Then $z^3$ is also even. + \pfln This implies that $x^3 + 0^3$ is even and $0^3 + z^3$ is even + \pfln Thus, $(x,0) \in S$ and $(0,z) \in S$ (by defn of S) + \pfln So, $(x,z) \in S \circ S$ + \end{subpf} + \pfln In all cases, $(x,z) \in S \circ S$ + \end{subpf} + OR + \pfln ($\supseteq$) Suppose $(x,z) \in S$ + \begin{subpf} + \pfln Note that $(x, x) \in S$ as $x^3 + x^3$ is even + \pfln Since $(x, x) \in S$ and $(x,z) \in S$, we have $(x, z) \in S \circ S$ (by defn of composition of relations) + \end{subpf} + \end{numpf*} + +\end{proof} + +\begin{proof} $R$ is asymmetric if and only if $R$ is antisymmetric and irreflexive. + \begin{numpf} + \pfln $\implies$ + \begin{subpf} + \pfln R is irreflexive (R is irreflexive $\implies$ R is antisymmetric and irreflexive) + \begin{subpf} + \pfln Let $x \in A$ s.t. $xRx \implies x \not R x$ (R is Asymmetric) + \pfln Since $x\not R x$, R is irreflexive (by defn of irreflexive) + \end{subpf} + \end{subpf} + \begin{subpf} + \pfln R is antisymmetric (Tutorial Qn 6c) + \end{subpf} + \pfln $\impliedby$ (R is antisymmetric and irreflexive $\implies$ asymmetry) + \begin{subpf} + \pfln Let $x, y \in A$, s.t. xRy is antisymmetric and irreflexive + \pfln There is 2 cases to consider, $x = y$ and $x \not = y$ + \pfln $x = y$ + \begin{subpf} + \pfln $xRx$ is not valid as it contradicts irreflexive, $\forall x \in A(x\not R x)$ + \pfln Therefore, $xRx \implies x\not R x$ + \end{subpf} + \pfln $x \not = y$ + \begin{subpf} + \pfln $xRy \land yRx \implies x = y$ + \end{subpf} + \end{subpf} + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ L07S26 Eg 14] $f: \mathbb{Q} \Rightarrow \mathbb{Q}$ by setting $f(x) = 3x+1, x \in Q$. Is $f$ injective? + Yes + \begin{numpf} + \pfln Let $x_1, x_2 \in \mathbb{Q}$ s.t. $f(x_1) = f(x_2)$ + \pfln Then $3x_1 + 1 = 3x_2 + 1$ + \pfln So $x_1 = x_2$ + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ L07S28 Eg 16] $f: \mathbb{Q} \Rightarrow \mathbb{Q}$ by setting $f(x) = 3x+1, x \in Q$. Is $f$ surjective? + Yes + \begin{numpf} + \pfln Take any $y \in \mathbb{Q}$ + \pfln Let $x = (y - 1) / 3$ + \pfln Then $x \in \mathbb{Q}$ and $f(x) = 3x + 1 = 3(\frac{y-1}{3}) + 1 = y$ + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ L07S34] If $g_1$ and $g_2$ are inverses of $f: X \Rightarrow Y$, then $g_1 = g_2$ + \begin{numpf} + \pfln Note that $g_1, g_2: Y \Rightarrow X$ + \pfln Since $g_1$ and $g_2$ are inverses of $f$, for all $x \in X$ and $y \in Y, x = g_1(y) \Leftrightarrow y = f(x) \Leftrightarrow x = g_2(y)$ + \pfln Therefore, $g_1 = g_2$ + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ Theorem 7.2.3] $f: X \Rightarrow Y$ is bijective iff $f$ has inverse + \begin{numpf} + \pfln ("if") Suppose $f$ has an inverse, say $g: Y \Rightarrow X$ + \begin{subpf} + \pfln We show injectivity of $f$ + \begin{subpf} + \pfln Let $x_1, x_2 \in X s.t. f(x_1) = f(x_2)$ + \pfln Define $y = f(x_1) = f(x_2)$ + \pfln Then $x_1 = g(y)$ and $x_2 = g(y)$ as $g$ is an inverse of $f$ + \pfln Hence $x_1 = x_2$ + \end{subpf} + \pfln We show surjectivity of f + \begin{subpf} + \pfln Let $y \in Y$ + \pfln Define $x = g(y)$ + \pfln Then $y = f(x)$ as g is an inverse of f + \end{subpf} + \pfln Therefore f is bijective + \end{subpf} + \pfln ("Only if") Suppose $f$ is bijective + \begin{subpf} + \pfln Then $\forall y \in Y\ \exists!x \in X(y = f(x))$ (by defn of bijection) + \pfln Define the function $g: Y \Rightarrow X$ by setting $g(y)$ to be the unique $x \in X$ s.t. $y = f(x)$ for all $y \in Y$ + \pfln This $g$ is well defined and is an inverse of $f$ (by defn of inverse function) + \end{subpf} + \pfln Therefore $f: X \Rightarrow Y$ is bijective iff $f$ has an inverse + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ S07S47] $(h \circ g) \circ f = h \circ (g \circ f)$ + \begin{numpf} + \pfln Domains of $(h \circ g) \circ f$ and $h \circ (g \circ f)$ are both $A$. + \pfln Codomains of $(h \circ g) \circ f$ and $h \circ (g \circ f)$ are both $D$. + \pfln For every $x \in A$, $((h \circ g) \circ f)(x) = (h \circ g)(f(x)) = h(g(f(x))) = h((g \circ f)(x)) = (h \circ (g \circ f))(x)$ + \end{numpf} + +\end{proof} + +\begin{proof}[\proofname\ Theorem 7.3.3] If $f: X \Rightarrow Y$ and $g: Y \Rightarrow Z$ are both injective, then $g \circ f$ is injective + \begin{numpf} + \pfln Suppose $f: X \Rightarrow Y$ and $g: Y \Rightarrow Z$ are injections and let $x_1, x_2 \in X$ such that $(g \circ f)(x_1) = (g \circ f)(x_2)$ + \pfln Then $g(f(x_1)) = g(f(x_2))$ (by defn of function composition) + \pfln Since $g$ is injective, so $f(x_1) = f(x_2)$ (by defn of injection) + \pfln Since $f$ is injective, so $x_1 = x_2$ (by defn of injection) + \pfln Therefore $g \circ f$ is injective + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ Theorem 7.3.4] If $f: X \Rightarrow Y$ and $g: Y \Rightarrow Z$ are both surjective, then $g \circ f$ is surjective + \begin{numpf} + \pfln Suppose $f: X \Rightarrow Y$ and $g: Y \Rightarrow Z$ are surjections and let $z \in Z$ such that $(g \circ f)(x_1) = (g \circ f)(x_2)$ + \pfln Since $g$ is surjective, so there is an element $y \in Y$ s.t. $g(y) = z$ (by defn of surjection) + \pfln Since $f$ is surjective, so there is an element $x \in X$ s.t. $f(x) = y$ (by defn of surjection) + \pfln Hence there exists an element $x \in X$ s.t. $(g \circ f)(x) = g(f(x)) = g(y) = z$ + \pfln Therefore, $g \circ f$ is surjective + \end{numpf} +\end{proof} + +\begin{proof}{\proofname\ Addition on $\mathbb{Z}_n$ is well defined} + \begin{numpf} + \pfln Let $[x_1], [y_1], [x_2], [y_2] \in \mathbb{Z}_n$ s.t. $[x_1] = [x_2]$ and $[y_1] = [y_2]$ + \pfln Then $x_1 \equiv x_2$ (mod n) and $y_1 \equiv y_2$ (mod n) (by defn of congruence) + \pfln Using defn of congruence to find $k, l \in \mathbb{Z}$ s.t. $x_1 - x_2 = nk$ and $y_1 - y_2 = nl$ + \pfln Note that $(x_1 + y_1) - (x_2 + y_2) = (x_1 - x_2) + (y_1 - y_2) = nk + nl = n(k+l)$ + \pfln So $x_1 + y_1$ = $x_2 + y_2$ (mod n) (by defn of congruence) + \pfln Therefore, $[x_1] + [y_1] = [x_1+y_1] = [x_2+y_2] = [x_2] + [y_2]$ (by lemma Rel.1 Equivalence classes) + \end{numpf} +\end{proof} + +\begin{proof}{\proofname\ Multiplication on $\mathbb{Z}_n$ is well defined} + \begin{numpf} + \pfln Let $[x_1], [y_1], [x_2], [y_2] \in \mathbb{Z}_n$ s.t. $[x_1] = [x_2]$ and $[y_1] = [y_2]$ + \pfln Then $x_1 \equiv x_2$ (mod n) and $y_1 \equiv y_2$ (mod n) (by defn of congruence) + \pfln Using defn of congruence to find $k, l \in \mathbb{Z}$ s.t. $x_1 - x_2 = nk$ and $y_1 - y_2 = nl$ + \pfln Note that $(x_1 \cdot y_1) - (x_2 \cdot y_2) = (nk + x_2) \cdot (nl + y_2) - (x_2 \cdot y_2) = n(nkl + ky_2 + lx_2)$ where $(nkl, ky_2, lx_2) \in \mathbb{Z}$ (Closure of integer addition) + \pfln So $x_1 \cdot y_1$ = $x_2 \cdot y_2$ (mod n) (by defn of congruence) + \pfln Therefore, $[x_1] \cdot [y_1] = [x_1\cdot y_1] = [x_2\cdot y_2] = [x_2] \cdot [y_2]$ (by lemma Rel.1 Equivalence classes) + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ Theorem 5.2.2] for all $n \geq 1, 1 + 2 + 3 + ... + n = \frac{n(n+1)}{2}$ + \begin{numpf} + \pfln Let $p(n) \equiv (1+2+...+n = \frac{n(n+1)}{2}, \forall n \in \mathbb{Z}^+$ + \pfln Basis step: $1 = \frac{1(1+1)}{2}$, therefore P(1) is true. + \pfln Assume $P(k)$ is true for some $k \geq 1$. That is $1+2+...+k = \frac{k(k+1)}{2}$ + \pfln Inductive Step: (To show P(k+1) is true) + \begin{subpf} + \pfln $1+2+...+k + (k+1) = \frac{k(k+1)}{2} + (k+1) = \frac{(k+1)((k+1)+1)}{2}$ + \pfln Therefore $P(k+1)$ is true + \end{subpf} + \pfln Therefore, $P(n)$ is true for $n\in \mathbb{Z}^+$ (We have proved P(1) and $P(k) \Rightarrow P(k+1)$) + \end{numpf} +\end{proof} + + +\begin{proof}[\proofname\ Theorem 5.2.3] for any real number $r \not = 1$, and any integers $n \geq 0, \sum^{n}_{i=0} r^i = \frac{r^{n+1}-1}{r-1}$ + \begin{numpf} + \pfln Let $P(n) \equiv (\sum^n_{i=0}r^i = \frac{r^{n+1}-1}{r-1}, r \not = 1, n \geq 0$ + \pfln Basis step: $r^0 = 1 = \frac{r^1 - 1}{r-1}$, therefore $P(0)$ is true + \pfln Assume P(k) is true for $k \geq 0$. That is, $\sum^k_{i=0}r^i = \frac{r^{k+1}-1}{r-1}$ + \pfln Inductive Step: (To show $P(k+1)$ is true) + \begin{subpf} + \pfln $\sum^{k+1}_{i=0}r^i = \sum^k_{i=0}r^i + r^{k+1} = \frac{r^{k+1}-1}{r-1} + r^{k+1} = \frac{r^{k+1}-1+r^{k+1}(r-1)}{r-1} = \frac{r^{((k+1)+1)}-1}{r-1}$ + \pfln Therefore $P(k+1)$ is true. + \end{subpf} + \pfln Therefore, $P(n)$ is true for $n \geq 0$ + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ Proposition 5.3.1] For all integers $n \geq 0, 2^{2n} - 1$ is divisible by 3 + \begin{numpf} + \pfln Let $P(n) \equiv (3 | (2^{2n} - 1))$ for all integers $n \geq 0$ + \pfln Basis Step: $2^{2 \cdot 0} - 1 = 0$ is divisible by 3, therefore P(0) is true + \pfln Assume P(k) is true for $k \geq 0$. That is $3 | (2^{2k} - 1)$ + \begin{subpf} + \pfln This means that $2^{2k} - 1 = 3r$ for some integer r (by defn of divisibility) + \end{subpf} + \pfln Inductive Step: To show $P(k+1)$ is true + \begin{subpf} + \pfln $2^{2(k+1)} - 1 = 2^{2k} \cdot 4 - 1 = 2^{2k}(3 \cdot 1) - 1 = 3 \cdot 2^{2k} + (2^{2k} - 1) = 3 \cdot 2^{2k} + 3r =3(2^{2k} + r)$ + \pfln Since $3 | 2^{2(k+1)} - 1$, therefore $P(k+1)$ is true + \end{subpf} + \pfln Therefore, P(n) is true for all integers $n \geq 0$ + \end{numpf} +\end{proof} + +\begin{proof}[\proofname\ Proposition 5.3.2] For all integers $n \geq 3, 2n+1 < 2^n$ + \begin{numpf} + \pfln Let $P(n) \equiv 2n+1 < 2^n$, for all integers $n \geq 3$ + \pfln Basis Step: $2(3) + 1 = 7 < 8 = 2^3$, therefore P(3) is true + \pfln Assume P(k) is true for $k \geq 3$. That is $2k+1 < 2^k$ + \pfln Inductive Step: To show $P(k+1)$ is true + \begin{subpf} + \pfln $2(k+1) + 1 = (2k + 1) + 2 < 2^k + 2 < 2^k + 2^k = 2^{k+1}$ (because $2 < 2^k$ for all integers $k \geq 2$ + \pfln Therefore P(k+1) is true + \end{subpf} + \pfln Therefore, P(n) is true for all integers $n \geq 3$ + \end{numpf} +\end{proof} + +\begin{proof} Any integer $> 1$ is divisible by a prime number (Proof by 2PI) + \begin{numpf} + \pfln Let $P(n) \equiv (n$ is divisible by a prime$)$, for $n > 1$ + \pfln Basis step: $P(2)$ is true since 2 is divisible by 2. + \pfln Inductive step: To show that for all integers $k \geq 2$, if $P(i)$ is true for all integers $i$ from 2 through $k$, then P(k+1) is also true. + \begin{subpf} + \pfln Case 1(k+1 is prime): In this case k+1 is divisible by a prime number which is itself + \pfln Case 2(k+1 is not prime): In this case: $k+1 = ab$ where $a$ and $b$ are integers with $1 < a < k + 1$ and $1 < b < k + 1$. + \begin{subpf} + \pfln Thus, in particular, $2 \leq a \leq k$ and so by inductive hypothesis, $a$ is divisible by a prime number $p$. + \pfln In addition, because $k+1 = ab$, so $k + 1$ is divisible by a + \pfln By transitivity of divisibility, $k+1$ is divisible by prime $p$ + \end{subpf} + \end{subpf} + \pfln Therefore, any integer greater than 1 is divisible by a prime + \end{numpf} +\end{proof} + +\begin{proof} For all integers $n \geq 12, n = 4a + 5b$, for some $a,b \in \mathbb{N}$ (Proof with 1PI) + \begin{numpf} + \pfln Let $P(n) \equiv$ (amount of $\$n$ can be formed by \$4 and \$5 coins) for $n \geq 12$ + \pfln Basis step: $12 = 3 \times 4$, so 3 \$4 can be used. Therefore, P(12) is true. + \pfln Assume P(k) is true for $k \geq 12$ + \pfln Inductive Step: (To show $P(k+1)$ is true.) + \begin{subpf} + \pfln Case 1: If a \$4 coin is used for \$k amount, replace it with a \$5 coin to make $\$(k+1)$ + \pfln Case 2: If a no \$4 coin is used for \$k amount, then $k \geq 15$, so there must be at least three \$5 coins. We can replace three \$5 coins with 4 \$4 coins to make $\$(k+1)$ + \pfln In both cases, P(k+1) is true. + \end{subpf} + \pfln Therefore, $P(n)$ is true for $n \geq 12$ + \end{numpf} +\end{proof} + +\begin{proof} For all integers $n \geq 12, n = 4a + 5b$, for some $a,b \in \mathbb{N}$ (Proof with 2PI) + \begin{numpf} + \pfln Let $P(n) \equiv (n = 4a + 5b)$ for some $a, b \in \mathbb{N}, n \geq 12$ + \pfln Basis step: Show $P(12), P(13), P(14), P(15)$ hold. + + $12 = 4 \cdot 3 + 5 \cdot 0; 13 = 4 \cdot 2 + 5 \cdot 1; 14 = 4 \cdot 1 + 5 \cdot 2; 15 = 4 \cdot 0 + 5 \cdot 3$ + \pfln Assume P(i) holds for $12 \leq i \leq k$ given some $k \geq 15$ + \pfln Inductive Step: (To show $P(k+1)$ is true.) + \begin{subpf} + \pfln $P(k-3)$ holds(by induction hypothesis), so $k-3 = 4a+5b$ for some $a, b \in \mathbb{N}$ + \pfln $k + 1 = (k-3)+4 = (4a+5b)+4 = 4(a+1) + 5b$ + \pfln Hence $P(k+1)$ is true + \end{subpf} + \pfln Therefore, $P(n)$ is true for $n \geq 12$ + \end{numpf} +\end{proof} + +\begin{proof} For any positive integer n, if $a_1, a_2,...,a_n$ and $b_1, b_2,...,b_n$ are real numbers, then $\sum^n_{i=1}(a_i+b_i) = \sum^n_{i=1}a_i + \sum^n_{i=1}b_i$ + \begin{numpf} + \pfln Let $P(n) = (\sum^n_{i=1}(a_i+b_i) = \sum^n_{i=1}a_i + \sum^n_{i=1}b_i$) for $n \geq 1$ + \pfln Basis step: P(1) is true since $\sum^1_{i=1}(a_i+b_i) = a_1 + b_1 = \sum^1_{i=1}a_i + \sum^1_{i=1}b_i$ + \pfln Inductive Hypothesis for some $k \geq 1$, $\sum^k_{i=1}(a_i+b_i) = \sum^k_{i=1}a_i + \sum^k_{i=1}b_i$ + \pfln Inductive Step: $\sum^{k+1}_{i=1}(a_i+b_i) = \sum^{k}_{i=1}(a_i+b_i) + (a_{k+1} + b_{k+1})$ (by defn of $\sum$)\\ + $ = \sum^k_{i=1}a_i + \sum^k_{i=1}b_i + (a_{k+1} + b_{k+1})$ (by inductive hypothesis)\\ + $ = \sum^k_{i=1}a_i + a_{k+1} + \sum^k_{i=1}b_i + b_{k+1}$ (by the associative and commutative laws of algebra)\\ + $ = \sum^{k+1}_{i=1}a_i + \sum^{k+1}_{i=1}b_i$ (by defn of $\sum$)\\ + Therefore $P(k+1)$ is true + \pfln Therefore $P(n)$ is true for any positive integer $n$ + \end{numpf} +\end{proof} + +\begin{proof} Pigeonhole Principle + \begin{numpf} + \pfln Note that $A$ is finite. Suppose $A = \{a_1, a_2, ..., a_m\}$ where $m = |A|$ + \pfln Injectivity of $f$ tells us that if $a_i \not = a_j$, then $f(a_i) \not = f(a_j)$ + \pfln So $f(a_1), f(a_2), ..., f(a_m)$ are $m$ different elements of $B$. + \pfln This shows that $|B| \geq m = |A|$ + \end{numpf} +\end{proof} + +\begin{proof} Dual Pigeonhole Principle + \begin{numpf} + \pfln Note that $B$ is finite. Suppose $B = \{b_1, b_2, ..., b_m\}$ where $m = |B|$ + \pfln For each $b_i$, use the surjectivity of $f$ to find $a_i \in A$ s.t. $f(a_i) = b_i$ + \pfln If $b_i \neq b_j$, then $f(a_i) \neq f(a_j)$ and so $a_i \neq a_j$ as $f$ is a function + \pfln So $a_1, a_2, ..., a_n$ are n different elements of A + \pfln This shows that $|A| \geq n = |B|$ + \end{numpf} +\end{proof} + +\end{document} diff --git a/cheatsheets/cs1231s/finals.pdf b/cheatsheets/cs1231s/finals.pdf new file mode 100644 index 0000000..9a19b71 Binary files /dev/null and b/cheatsheets/cs1231s/finals.pdf differ diff --git a/cheatsheets/cs1231s/finals.tex b/cheatsheets/cs1231s/finals.tex new file mode 100644 index 0000000..b6efcef --- /dev/null +++ b/cheatsheets/cs1231s/finals.tex @@ -0,0 +1,1188 @@ +\documentclass[a4paper]{article} +\usepackage[T1]{fontenc} +\usepackage{1231num} +\usepackage{amsmath} +\usepackage{amsthm} +\usepackage{amssymb} + +\usepackage{lscape} +\usepackage{pdflscape} + +\usepackage[margin=0.5in]{geometry} +\usepackage[skip=0pt]{parskip} +\setlength{\parindent}{0pt} + +\theoremstyle{definition} +\newtheorem*{defn}{Defn} + +\newtheorem*{propos}{Proposition} +\newtheorem*{corollary}{Corollary} +\newtheorem*{lemma}{Lemma} + +\renewcommand{\qedsymbol}{} + +\newtheorem{innertheorem}{Theorem} +\newenvironment{theorem}[1] + {\renewcommand\theinnertheorem{#1}\innertheorem} + {\endinnertheorem} + + +\author{Yadunand Prem} + +\title{Finals Cheatsheet} + +\begin{document} +\section{Tables} + +\begin{tabular} {|l|c|c|} + Commutative & $p \land q \equiv q \land p$ & $p \lor q \equiv q \lor p$\\ + Associative & $p \land q \land r \equiv (p \land q) \land r$&\\ + Distributive & $p \land (q \lor r) \equiv (p \land q) \lor (p \land r)$&$p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)$\\ + Identity & $p \land \text{true} \equiv p$ & $p \lor \text{false} \equiv p$\\ + Negation & $p \lor \sim p \equiv \text{true}$ & $p \land \sim p \equiv \text{false}$\\ + Double Negative & $\sim(\sim p) \equiv p$ & \\ + Idempotent & $p \lor p \equiv p$ & $p \land p \equiv p$\\ + Universal bound & $p \lor \text{true} \equiv \text{true}$ & $p \land \text{false} \equiv \text{false}$\\ + de Morgan's & $\sim(p \land q) \equiv \sim p \lor \sim q$ & $\sim(p \lor q) \equiv \sim p \land \sim q$\\ + Absorption & $p \lor (p \land q) \equiv p$ & $p \land (p \lor q) \equiv p$\\ + Implication & $p \Rightarrow q \equiv \sim p \lor q$ & $$\\ + $\sim$(Implication) & $\sim (p \Rightarrow q) \equiv p \land \sim q$ & \\ + \hline & & \\ + Modus Ponens &$p \implies q, p$& $q$ \\ + Modus Tollens &$p \implies q, \sim q$& $\sim p$ \\ + Generalization &$p$& $p \lor q$ \\ + Specialization &$p \land q$& $p$ \\ + Conjunction &$p, q$& $p \land q$ \\ + Elimination &$p \lor q, \sim q$& $p$ \\ + Transitivity &$p \implies q, q \implies r$& $p \implies r$ \\ + Division into cases &$p \land q, p \implies r, q \implies r$& $r$ \\ + Contradiction &$\sim p \implies \text{false}$& $p$ \\ + \hline & & \\ + Commutative & $A \cup B = B \cup A$ & \\ + Associative & $(A \cup B) \cup C = A \cup (B \cup C)$ & \\ + Distributive & $A \cup (B \cap C) = (A \cup B) \cap (A \cup C)$ & $A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$\\ + Identity & $A \cup \emptyset = A$ & $A \cap U = A$\\ + Complement & $A \cup \bar A = U$ & $A \cap \bar A = \emptyset$\\ + Double Complement & $\bar{\bar A} = A$ & \\ + Idempotent & $A \cup A = A$ & $A \cap A = A$\\ + Universal Bound & $A \cup U = U$ & $A \cap \emptyset = \emptyset$ \\ + De Morgan's & $\overline{A \cup B} = \bar{A} \cap \bar{B}$ & $\overline{A \cap B} = \bar{A} \cup \bar{B}$\\ + Absorption & $A \cup (A \cap B) = A$ & $A \cap (A \cup B) = A$\\ + Complements of U and $\emptyset$ & $\bar U =\emptyset$ & $\bar \emptyset = U$\\ + Set Difference & $A \setminus B = A \cap \bar B$ &\\ + \hline & & \\ + F1 Commutative & $a + b = b + a$ & $ab = ba$ \\ + F2 Associative & $(a + b)+c = a + (b + c)$ & $(ab)c = a(bc)$ \\ + F3 Distributive & $a(b+c) = ab + ac$ & $(b+c)a = ba + ca$ \\ + F4 Identity & $0 +a = a + 0 = a$ & $1 \cdot a = a \cdot 1 = a $ \\ + F5 Additive inverses & $a + (-a) = (-a) + a = 0$ & \\ + F6 Reciprocals & $a \cdot \frac{1}{a} = \frac{1}{a} \cdot a = 1$ & $a \not = 0$ \\ + \hline & & \\ + T1 Cancellation Add & $a + b = a + c$ & $b = c$ \\ + T2 Possibility of Sub & There is one $x, a + x = b$ & $x = b - a$ \\ + T3 & $b - a = b + (-a)$ & \\ + T4 & $-(-a) = a$ & \\ + T5 & $a(b-c)=ab-ac$ & \\ + T6 & $0 \cdot a = a \cdot 0 = 0$ & \\ + T7 Cancellation Mul & $ab = ac$ & $b = c, a \not = 0$ \\ + T8 Possibility of Div & $a \not = 0, ax = b$ & $x = \frac{b}{a}$ \\ + T9 & $a \not = 0, \frac{b}{a} = b \cdot a^{-1}$ & \\ + T10 & $a \not = 0, (a^{-1})^{-1} = a$ & \\ + T11 Zero Product& $ab = 0 \Rightarrow a = 0 \lor b = 0$ & \\ + T12 Mul with -ve & $(-a)b = a(-b) - -(ab)$ & $-\frac{a}{b} = \frac{-a}{b} = \frac{a}{-b}$\\ + T13 Equiv Frac & $\frac{a}{b} = \frac{ac}{bc}$ & $b \not = 0, c \not = 0$\\ + T14 Add Frac & $\frac{a}{b} + \frac{c}{d} = \frac{ad + bc}{bd}$ & $b \not = 0, d \not = 0$\\ + T15 Mul Frac & $\frac{a}{b} \cdot \frac{c}{d} = \frac{ac}{bd}$ & $b \not = 0, d \not = 0$\\ + T16 Div Frac & $\frac{\frac{a}{b}}{\frac{c}{d}} = \frac{ac}{bd}$ & $b \not = 0, d \not = 0$\\ +\end{tabular} + +\begin{tabular} {|l|c|c|} + \hline & & \\ + Ord1 & $\forall a,b \in \mathbb{R}^+$ & $a + b > 0, ab > 0$\\ + Ord2 & $\forall a,b \in \mathbb{R}_{\not = 0}$ & $a$ is positive or negative and not both\\ + Ord3 & 0 is not positive & \\ + $a < b$ & means $b + (-a)$ is positive & \\ + $a \leq b$ & means $a < b$ or $a = b$ & \\ + $a < 0$ & means a is negative& \\ + T17 Trichotomy Law & $a < b \lor b > a \lor a = b$ & \\ + T18 Transitive Law & $a < b$ and $b < c$ & $a < c$\\ + T19 & $a < b$ & $a + c < b + c$ \\ + T20 & $a < b$ and $c > 0$ & $ac < bc$ \\ + T21 & $a \not = 0$ & $a^2 > 0$ \\ + T22 & $1 > 0$ & \\ + T23 & $a < b$ and $c < 0$ & $ac > bc$ \\ + T24 & $a < b$ & $-a > -b$ \\ + T25 & $ab > 0$ & a and b are both positive or negative \\ + T26 & $a < c$ and $b < d$ & $a+b < c+d$ \\ + T27 & $0 < a < c$ and $<0 < b < d$ & $0 < ab < cd$ \\ +\end{tabular} + +\section{Math} + +\begin{defn}{Even and Odd Integers}\\ + n is even $\Leftrightarrow \exists$ an integer $k$ s.t. $n = 2k$\\ + n is odd $\Leftrightarrow \exists$ an integer $k$ s.t. $n = 2k + 1$ +\end{defn} + +\begin{defn}{Divisibility}\\ + $n$ and $d$ are integers and $d \not= 0$ \\ + $d | n \Leftrightarrow \exists k \in \mathbb{Z}$ s.t. $n = dk$ +\end{defn} + +\begin{theorem}{4.2.1} Every Integer is a rational number \end{theorem} + +\begin{theorem}{4.2.2} The sum of any two rational numbers is rational \end{theorem} + +\begin{theorem}{4.3.1} For all $a, b \in \mathbb{Z}^+$, if $a | b$, then $a \leq b$ \end{theorem} + +\begin{theorem}{4.3.2} Only divisors of $1$ are $1$ and $-1$ \end{theorem} + +\begin{theorem}{4.3.3} $\forall a, b, c \in \mathbb{Z}$ if $a | b$, $b | c$, $a | c$ \end{theorem} + +\begin{theorem}{4.6.1} There is no greatest integer \end{theorem} + +\begin{propos}{4.6.4} For all integers $n$, if $n^2$ is even, then $n$ is even. \end{propos} + +\begin{defn}{Rational} $r$ is rational $\Leftrightarrow \exists a, b \in \mathbb{Z}$ s.t. $r = \frac{a}{b}$ and $b \not=0$ \end{defn} + +\begin{defn}{Fraction in lowest term:} fraction $\frac{a}{b}$ is lowest term if largest $\mathbb{Z}$ that divies both $a$ and $b$ is 1 \end{defn} + +\begin{theorem}{4.7.1} $\sqrt{2}$ is irrational \end{theorem} + +\section{Logic of Combound Statements} + +\begin{theorem}{3.2.1} Negation of universal stmt $\sim(\forall x \in D, P(x)) \equiv \exists x \in D$ s.t. $\sim P(x)$ \end{theorem} + +\begin{theorem}{3.2.1} Negation of existential stmt $\sim(\exists x \in D$ s.t. $P(x)) \equiv \forall x \in D, \sim P(x)$ \end{theorem} + +\begin{defn}{Contrapositive} of $p \Rightarrow q \equiv \sim q \Rightarrow \sim p$ \end{defn} + +\begin{defn}{Converse} of $p \Rightarrow q$ is $q \Rightarrow p$ \end{defn} + +\begin{defn}{Inverse} of $p \Rightarrow q$ is $\sim p \Rightarrow \sim q$ \end{defn} + +\begin{defn}{Only if:} $p$ only if $q$ means $\sim q \Rightarrow \sim p \equiv p \Rightarrow q$ \end{defn} + +\begin{defn}{Biconditional:} $p \Leftrightarrow q \equiv (p \Rightarrow q) \land (q \Rightarrow p)$ \end{defn} + +\begin{defn} $r$ is sufficient condition for $s$ means if $r$ then $s$, $r \Rightarrow s$ \end{defn} + +\begin{defn} $r$ is necessary condition for $s$ means if $\sim r$ then $\sim s$, $s \Rightarrow r$ \end{defn} + +\begin{defn}{Proof by Contradiction}\\ If you can show that the supposition that sttatement $p$ is false leads to a contradiction, then you can conclude that $p$ is true \end{defn} + +\section{Methods of Proof} + +\begin{tabular} {|c|l|} + \hline + Statement & Proof Approach \\ + $\forall x \in D\ P(X)$ & Direct: Pick arbitrary x, prove P is true for that x. \\ + & Contradiction: Suppose not, i.e. $ \exists x(\sim p)$... Hence supposition $\sim p$ is false (P3) \\ + \hline + $\exists x \in D\ P(X)$ & Direct: Find x where P is true. \\ + & Contradiction: Suppose not, i.e. $\forall x (\sim p)$... Hence supposition $\sim p$ is false (P3) \\ + \hline + $P \Rightarrow Q$ & Direct: Assume P is true, prove Q \\ + & Contradiction: Assume P is true and Q is false, then derive contradiction \\ + & Contrapositive: Assume $\sim Q$, then prove $\sim P$ \\ + \hline + $P \Leftrightarrow Q$ & Prove both $P \Rightarrow Q$ and $Q \Rightarrow P$ \\ + \hline + $xRy$. Prove R is equivalence & Prove Reflexive, Symmetric and Transitive \\ + \hline + +\end{tabular} + +\begin{defn}{Proof by Contraposition}\\ + 1. Statement to be proved $\forall x \in D\ (P(x) \Rightarrow Q(x))$\\ + 2. Contrapositive Form: $\forall x \in D\ (\sim Q(x) \Rightarrow \sim P(x))$\\ + 3. Prove by direct proof\\ + 3.1 Suppose x is an element of D s.t. $Q(X)$ is false\\ + 3.2 Show that P(x) is false.\\ + 4. Therefore, original statement is true +\end{defn} + + +\section{Set Theory} + +\begin{defn}{Set: Unordered collection of objects}\\ Order and duplicates don't matter \end{defn} + +\begin{defn}{Membership of Set $\in$: } If $S$ is set, $x \in S$ means $x$ is an element of $S$ \end{defn} + +\begin{defn}{Cardinality of Set $|S|$: } The number of elements in $S$ \end{defn} + +Common Sets: + +$\mathbb{N}$ - Natural Numbers, $\{0, 1, 2\}$ + +$\mathbb{Z}$ - Integers + +$\mathbb{Q}$ - Rational + +$\mathbb{R}$ - Real + +$\mathbb{C}$ - Complex + +$\mathbb{Z}^\pm$ - Positive/Negative Integers + +\begin{defn}{Subset} + $A \subseteq B \Leftrightarrow$ Every element of $A$ is also an element of $B$\\ + $A \subseteq B \Leftrightarrow \forall x(x\in A \Rightarrow x \in B)$ +\end{defn} + +\begin{defn}{Proper Subset} $A \subsetneq B \Leftrightarrow (A \subseteq B \land A \not = B)$ \end{defn} + +\begin{theorem}{6.2.4} An empty set is a subset of every set, i.e. $\emptyset \subseteq A$ for all sets $A$ \end{theorem} + +\begin{defn}{Cartesian Product} $A \times B = \{(a, b): a \in A \land b \in B\} $ \end{defn} + +\begin{defn}{Set Equality} + $A = B \Leftrightarrow A \subseteq B \land B \subseteq A$ \\ + $A = B \Leftrightarrow \forall x (x \in A \Leftrightarrow x \in B)$ +\end{defn} + +\begin{defn}{Union:} $A \cup B = \{x \in U: x \in A \lor x \in B\}$ \end{defn} + +\begin{defn}{Intersection:} $A \cap B = \{x \in U: x \in A \land x \in B\}$ \end{defn} + +\begin{defn}{Difference:} $B \setminus A = \{x \in U: x \in B \land x \not\in A\}$ \end{defn} + +\begin{defn}{Disjoint:} $A \cap B = \emptyset$ \end{defn} + +\begin{theorem}{4.4.1} Quotient-Remainder + $n \in \mathbb{Z}, d \in \mathbb{Z}^+$\\ there exists unique integers q and r such that $n = dq + r$ and $0 \leq r < d$ +\end{theorem} + +\begin{defn}{Power Set:} The set of all subsets of $A$, has $2^n$ elements. \end{defn} + +\begin{theorem}{6.3.1} + Suppose $A$ is a finite set with $n$ elements, then $P(A)$ has $2^n$ elements. + $|P(A)| = 2^{|n|}$ +\end{theorem} + +\begin{defn}{Cartesian Product of $A_n$} + $= A_1 \times A_2 \times ... \times A_n = \{(a_1, a_2,...a_n): a_1 \in A_1 \land a_2 \in A_2...$ +\end{defn} + +\begin{theorem}{6.2.1} Subset Relations + \begin{numpf*} + \pfln Inclusion of Intersection: $A \cap B \subseteq A, A \cap B \subseteq B$ + \pfln Inclusion in Union $A \subseteq A \cup B, B \subseteq A \cup B$ + \pfln Transitive Property of Substs: $A \subseteq B \land B \subseteq C \Rightarrow A \subseteq C$ + \end{numpf*} +\end{theorem} + +\section{Relations} + +\begin{defn} Relation from A to B is a subset of $A \times B$\\ + Given an ordered pair$(x, y) \in A\times B$, $x$ is + related to y by $R$ is written $xRy \Leftrightarrow (x, y) \in R$ +\end{defn} + +\begin{defn} Domain, Co-domain, Range\\ + Let $A$ and $B$ be sets and $R$ be a relation from $A$ to $B$ + \begin{numpf*} + \pfln Domain of R: is set $\{a \in A: aRb$ for some $b \in B\}$ + \pfln Codomain of R: Set B + \pfln Range of R: is set $\{b \in B: aRb$ for some $a \in A\}$ + \end{numpf*} +\end{defn} + +\begin{defn} Inverse Relation\\ + Let $R$ be a relation from $A$ to $B$, + $R^{-1} = \{(y, x) \in B\times A: (x, y) \in R\}$\\ + $\forall x \in A, \forall y \in B ((y, x) \in R^{-1} \Leftrightarrow (x, y) \in R)$ +\end{defn} + +\begin{defn} + Relation on a Set $A$ is a relation from $A$ to $A$. +\end{defn} + +\begin{defn} Composition of Relations\\ + A, B and C be sets. $R \subseteq A \times B$ be a relation. $S \subset B \times C$ be relation. Composition of R with S, denoted $S \circ R$ is relation from A to C such that: \\ + $\forall x \in A, \forall z \in C(x S \circ R z \Leftrightarrow (\exists y \in B (xRy \land ySz)))$ +\end{defn} + +\begin{propos} Composition is Associative + $A, B, C, D$ be sets. $R \subseteq A \times B$, $S \subseteq B \times C$, $T \subseteq C \times D$\\ + $T \circ ( S \circ R) = T \circ S \circ R$ +\end{propos} + +\begin{propos} Inverse of Composition + $A, B, C$ be sets. $R \subseteq A \times B$, $S \subseteq B \times C$\\ + $(S \circ R)^{-1} = R^{-1} \circ S^{-1}$ +\end{propos} + +\begin{defn} \textbf{Reflexivity, Symmetry, Transitivity} + \begin{numpf*} + \pfln Reflexivity: $\forall x \in A (xRx)$ + \pfln Symmetry: $\forall x,y \in A (xRy \Rightarrow yRx)$ + \pfln Transitivity:$\forall x,y,z \in A (xRy \land yRz \Rightarrow xRz)$ + \end{numpf*} + Refer to proof 6 +\end{defn} + +\begin{defn} Transitive Closure\\ + Transitive closure of R is relation $R^t$ on A that satiesfies + \begin{numpf*} + \pfln $R^t$ is transitive + \pfln $R \subseteq R^t$ + \pfln If $S$ is any other transitive relation that contains $R$, then $R^t \subseteq S$ + \end{numpf*} +\end{defn} + +\begin{defn} Partition\\ + $P$ is partition of set A if + \begin{numpf*} + \pfln $P$ is a set of which all elements are non empty subsets of A, $\emptyset \not = S \subseteq A$ for all $S \in P$ + \pfln Every element of $A$ is in exactly on element of P, \\ + $\forall x \in A\ \exists S \in P (x \in S)$ and \\ + $\forall x \in A\ \exists S_1, S_2 \in P(x \in S_1 \land x \in S_2 \Rightarrow S_1 = S_2)$ + \end{numpf*} + OR $\forall x \in A\ \exists!S \in P(x \in S)$\\ + Elements of a partition are called components +\end{defn} + +\begin{defn} Relation Induced by a partition\\ + Given partition $P$ of $A$, the relation $R$ induced by partition: \\ + $\forall x, y \in A, xRy \Rightarrow \exists$ a component of $S$ of $P$ s.t. $x, y \in S$ +\end{defn} + +\begin{theorem}{8.3.1}[Relation Induced by a Partition] + Let $A$ be a set with a partition and let R be a relation induced by the partition. Then $R$ is reflexive, symmetric and transitive +\end{theorem} + +\begin{defn}[Equivalence Relation] + $A$ be set and $R$ be relation. $R$ is equivalence relation iff $R$ is reflexive, symmetric and transitive +\end{defn} + +\begin{defn} Equivalence Class\\ + Suppose $A$ is set and $\sim$ is equivalence relation on A. For each $A \in A$, equivalence class of $a$, denoted $[a]$ and called class of $a$ is set of all elements $x \in A$ s.t. $a\sim x$\\ + $[a]_{\sim} = \{x \in A: a \sim x \}$ +\end{defn} + +\begin{theorem}{8.3.4} The partition induced by an Equivalence Relation\\ + If $A$ is a set and $R$ is an equivalence relation on $A$, then distinct equivalence classes of $R$ form a partition of $A$; that is, the union of the equivalence classes is all of $A$, and the intersection of any 2 disctinct classes is empty. +\end{theorem} + +\begin{defn} Congruence\\ + Let $a, b \in \mathbb{Z}$ and $n \in \mathbb{Z}^+$. Then $a$ is congruent to $b$ modulo $n$ iff $a - b = nk$, for some $k \in \mathbb{Z}$. In other words, $n | (a - b)$. We write $a \equiv b (\text{mod}\ n)$ +\end{defn} + +\begin{defn} Set of equivalence classes\\ + Let $A$ be set and $\sim$ be an equivalence relation on $A$. Denote by $A/\sim$, the set of all equivalence classes with respect to $\sim$, i.e. + + $A/\sim = \{[x]_\sim: x \in A\}$ +\end{defn} + +\begin{theorem}{Equivalence Classes} form a partition + Let $\sim$ be an equiv. relation on $A$. Then $A/\sim$ is a partition of A. +\end{theorem} + +\begin{defn}[Antisymmetry] + $R$ is antisymmetric iff $\forall x, y \in A(xRy \land yRx \Rightarrow x = y)$ \textit{(DOES NOT IMPLY NOT SYMMETRIC)} +\end{defn} + +\begin{defn}[Partial Order Relation] + $R$ is Partial Order iff R is \textit{reflexive}, \textit{antisymmetric} and \textit{transitive}. +\end{defn} + +\begin{defn}{Partially Ordered Set} + Set A is called poset with respect to partial order relation $R$ on $A$, denoted by $(A, R)$ (Proof 7) +\end{defn} + +\begin{defn}{$x \preccurlyeq y$} + is used as a general partial order relation notation +\end{defn} + +\begin{defn}[Hasse Diagram] + Let $\preccurlyeq$ be a partial order on set $A$. Hasse diagram satisfies the following condition for all distinct $x, y, m \in A$ \\ + If $x \preccurlyeq y$ and no $m \in A$ is s.t. $x \preccurlyeq m \preccurlyeq y$, then x is placed below y with a line joining them, else no line joins $x$ and $y$. +\end{defn} + +\begin{defn}[Comparability] + $a, b \in A$ are comparable iff $a \preccurlyeq b$ or $b \preccurlyeq a$. Otherwise, they are \textbf{noncomparable} +\end{defn} + +\begin{defn}[Maximal, Minimal, Largest Smallest] + Set $A$ be partially ordered w.r.t. a relation $\preccurlyeq$ and $c \in A$ + \begin{numpf} + \pfln c is maximal element of $A$ iff $\forall x \in A$, either $x \preccurlyeq c$ or $x$ and $c$ are non-comparable. OR $\forall x in A(c \preccurlyeq x \Rightarrow c = x)$ + \pfln c is minimal element of $A$ iff $\forall x \in A$, either $c \preccurlyeq x$ or $x$ and $c$ are non-comparable. OR $\forall x in A(x \preccurlyeq c \Rightarrow c = x)$ + \pfln c is largest element of $A$ iff $\forall x \in A (x \preccurlyeq c)$ + \pfln c is smallest element of $A$ iff $\forall x \in A (c \preccurlyeq x)$ + \end{numpf} +\end{defn} + +\begin{propos} A smallest element is minimal\\ + Consider a partial order $\preccurlyeq$ on set $A$. Any smallest element is minimal. + \begin{numpf} + \pfln Let $c$ be smallest elemnt + \pfln Take any $x \in A$ s.t. $x \preccurlyeq c$ + \pfln By smallestness, we know $c \preccurlyeq x$ too. + \pfln So $c = x$ by antisymmetry + \end{numpf} +\end{propos} + +\begin{defn}[Total Order Relations] All elements of the set are comparable\\ + R is total order iff $R$ is a partial order and $\forall x, y \in A (xRy \lor yRx)$ +\end{defn} + +\begin{defn}[Linearization of a partial order] + Let $\preccurlyeq$ be a partial order on set $A$. A linearization of $\preccurlyeq$ is a total order $\preccurlyeq *$ on $A$ s.t. $\forall x, y \in A (x \preccurlyeq y \Rightarrow x \preccurlyeq *\ y)$ +\end{defn} + +\begin{defn}[Kahn's Algorithm] + Input: A finite set $A$ and partial order $\preccurlyeq$ on $A$ + \begin{numpf} + \pfln Set $A_0 := A$ and $i := 0$ + \pfln Repeat until $A_i = \emptyset$ + \begin{subpf} + \pfln Find minimal element $c_i$ of $A_i$ wrt $\preccurlyeq$ + \pfln Set $A_{i+1} = A_i \setminus {c_i}$ + \pfln Set $i = i+1$ + \end{subpf} + \end{numpf} + + Output: A linearization $\preccurlyeq *$ of $\preccurlyeq$ defined by setting, for all indicies $i, j$\\ $c_i \preccurlyeq*\ c_j \Leftrightarrow i \leq j$ +\end{defn} + +\begin{defn}[Well ordered set] Let $\preccurlyeq$ be a total order on set $A$. $A$ is well ordered iff every nonempty subset of A contains a smallest element. OR\\ + $\forall S \in P(A), S \not = \emptyset \Rightarrow (\exists x \in S \forall y \in S (x \preccurlyeq y))$ E.g. $(\mathbb{N}, \leq)$ is well ordered but $(\mathbb{Z}, \leq)$ is not as there is no smallest integer (Theorem 4.6.1) + +\end{defn} + +\subsection*{Functions} +\begin{defn}[Function] A function f from set $X$ to set $Y$, denoted $f: X \Rightarrow Y$ is a relation satisfying the following\\ + (F1) $\forall x \in X, \exists y \in Y (x,y) \in f$\\ + (F2) $\forall x \in X, \forall y_1, y_2 \in Y(((x, y_1) \in f \land (x, y_2) \in f) \Rightarrow y_1 = y_2)$ + + OR + + Let $f$ be a relation on sets $X$ and $Y$, i.e. $f \subseteq X \times Y$. Then $f$ is a function from $X$ to $Y$ denoted $f:X \Rightarrow Y$, iff $\forall x \in X\ \exists! y \in Y (x, y) \in f$ +\end{defn} + +\begin{defn}[Argument, Image, Preimage, input, output] Let $f:X \Rightarrow Y$ be fn. We write $f(x) = y$ iff $(x, y) \in f$ + + $f$ sends/maps x to y is also $x \overset {f}{\Rightarrow} y$ or $f:x \mapsto y$. $x$ is \textbf{argument} of $f$. + + $f(x)$ is read "f of x" or "the \textbf{output} of f for the \textbf{input} x", or "value of $f$ at $x$ or "image of $x$ under $f$" + + If $f(x) = y$, then $x$ is a \textbf{preimage} of y +\end{defn} + +\begin{defn}[Setwise image and preimage] Let $f: X \Rightarrow Y$ be a fn from set $X$ to $Y$ + + - If $A \subseteq X$, then let $f(A) = \{f(x): x \in A\}$\\ + - If $B \subseteq Y$, then let $f^{-1}(B) = \{x \in X: f(x) \in B\}$\\ + $f(A)$ is the \textbf{setwise image} of $A$ and $f^{-1}(B)$ the \textbf{setwise preimage} of $B$ under $f$. This is \textbf{NOT} the inverse function + + If $f^{-1}(\alpha), \alpha$ is a set, $f^{-1}$ is setwise preimage. else if $x$ member of codomain, $f^{-1}(x)$ is inverse function. $f^{-1}(\alpha)$ need not be function. Use $f^{-1}(\{b\})$ for setwise preimage of single element in codomain +\end{defn} + +\begin{defn}[Domain, Co-Domain, Range] Let $f: X \Rightarrow Y$ fn from set $X$ to $Y$. + + X is \textbf{domain} of $f$ and $Y$ the \textbf{co-domain} of $f$. + + \textbf{Range} of $f$ is the (setwise) image of $X$ under f: $\{y \in Y: y = f(x)$ for some $x \in X\}$. Range $\subseteq$ Co-Domain +\end{defn} + +\begin{defn}[Sequence] Sequence $a_0,a_1,a_2,...$ can be represented by a function $a$ whos domain is $\mathbb{Z}_{\geq0}$ that satisfies $a(n) = a_n$ for every $n \in \mathbb{Z}_{\geq0}$ + + Any function whos domain is $\mathbb{Z}_{\geq m}$ for some $m \in Z$ represents a sequence + + Fibonacci Sequence: $F(0) = 0, F(1) = 1, F(n+2) = F(n+1) + F(n)$ +\end{defn} + +\begin{defn}[String] Let A be a set. A \textbf{string} or a word over $A$ is an expression in the form of $a_0a_1a_2...a_{l-1}$ where $l \in \mathbb{Z}_{\geq 0}$ and $a_0,a_1,a_2,...,a_{l-1} \in A$. + + $l$ is called length of string. Empty string $\varepsilon$ is the string of length 0. + + Let $A*$ denote the set of all strings over $A$ +\end{defn} + +\begin{defn}[Equality of Sequences] Given two sequences $a_0,a_1,a_2...$ and $b_0,b_1,b_2,...$ defined by fn $a(n) = a_n$ and $b(n) = b_n$ for every $n \in \mathbb{Z}_{\geq0}$, two sequences are equal if and only if $a(n) = b(n)$ for every $n \in \mathbb{Z}_{\geq0}$ +\end{defn} + +\begin{defn}[Equality of Strings] Given two sequences $s1=a_0a_1a_2...a_{l-1}$ and $s2 = b_0 b_1 b_2, ...,b_{l-1}$ where $l \in \mathbb{Z}_{\geq0}$, we say that $s1 = s2$ if and only if $a_i = b_i$ for all $i \in {0,1,2,...,l-1}$ +\end{defn} + +\begin{theorem}{7.1.1 Function Equality} + + Two functions $f: A \Rightarrow B$ and $g: C \Rightarrow D$ are equal if i.e. $f = g$, iff (i) $A = C$ and $B = D$ and (ii) $f(x) = g(x) \forall x \in A$ +\end{theorem} + +\begin{defn}[Injection] One to one functions: + $\forall x_1, x_2 \in X (f(x_1) = f(x_2) \Rightarrow x_1 = x_2)$\\ + or the contrapositive: $x_1 \not = x_2 \Rightarrow f(x_1) \not = f(x_2)$ + +\end{defn} +\begin{defn}[Surjection] Onto function: + $\forall y \in Y \exists x \in X (y = f(x))$\\ + Every element in co-domain has a preimage. So range = co-domain. (Every element in Y has an x) + +\end{defn} + +\begin{defn}[Bijection] One to one correspondence: + $\forall y \in Y\ \exists! x \in X(y = f(x))$ +\end{defn} + +\begin{defn}[Inverse Functions] Let $f: X \Rightarrow Y$. Then $g: Y \Rightarrow X$ is an \textbf{inverse} of f iff\\ + $\forall x \in X, \forall y \in Y (y = f(x) \Leftrightarrow x = g(y))$ + inverse of $f$ is $f^{-1}$ +\end{defn} + + +\begin{propos}[Uniqueness of Inverse] If $g_1$ and $g_2$ are inverses of $f: X \Rightarrow Y$, then $g_1 = g_2$ (Proof S07L34) +\end{propos} + +\begin{theorem}{7.2.3} If $f: X \Rightarrow Y$ is a bijection, then $f^{-1}: Y \Rightarrow X$ is also a bijection. In other words, $f: X \Rightarrow Y$ is bijective iff $f$ has an inverse +\end{theorem} + +\begin{defn}[Composition of Functions] Let $f: X \Rightarrow Y$ and $g: Y \Rightarrow Z$ be fns + + $g \circ f: X \Rightarrow Z$ is $(g \circ f)(x) = g(f(x)) \forall x \in X$ +\end{defn} + +\begin{theorem}{7.3.1} Composition with an Identity Function + + If $f: X \Rightarrow Y$ and $id_x$ is identity fn on $X$ and $id_y$ is identity fn on Y, then + + $f \circ id_x = f$ and $id_y \circ f = f$ +\end{theorem} + +\begin{theorem}{7.3.2} Composition of a Function with its inverse + + If $f: X \Rightarrow Y$ is a bijection with inverse function $f^{-1}: Y \Rightarrow X$, then $f^{-1} \circ f = id_x$ and $f \circ f^{-1} = id_y$ +\end{theorem} + +\begin{theorem}{Associativity of Function Composition} + + Let $f: A \Rightarrow B, g: B \Rightarrow C, h: C \Rightarrow D$. Then $(h \circ g) \circ f = h \circ (g \circ f)$ +\end{theorem} + +\begin{defn}[Noncommutativity of Function Composition] + $(g \circ f) \not = (f \circ g)$ +\end{defn} + +\begin{theorem}{7.3.3} Composition of Injections + + If $f: X \Rightarrow Y$ and $g: Y \Rightarrow Z$ are both injective, then $g \circ f$ is injective +\end{theorem} +\begin{theorem}{7.3.4} Composition of Surjections + + If $f: X \Rightarrow Y$ and $g: Y \Rightarrow Z$ are both surjective, then $g \circ f$ is surjective +\end{theorem} + +\begin{defn}[$\mathbb{Z}/ \sim_n$] The quotient $\mathbb{Z}/\sim_n$ where $\sim_n$ is the congruence-mod-n relation on $\mathbb{Z}$, is denoted $\mathbb{Z}_n$ + + E.g. $\mathbb{Z}_3 = \{\{3k:k \in Z\}, \{3k + 1: k \in Z\}, \{3k + 2: k \in Z\}\}$ +\end{defn} + +\begin{defn}[Addition and Multiplication on $\mathbb{Z}_n$] Whenever $[x], [y] \in \mathbb{Z}_n$ + + $[x] + [y] = [x + y]$ and $[x] \cdot [y] = [x \cdot y]$ +\end{defn} + +\subsection*{Function Proofs} + +\begin{proof} Prove relation is function: T06Q1 $\forall x, y \in \mathbb{N} (xRy \iff x^2 = y^2)$ + \begin{numpf*} + \pfln $\forall x \in \mathbb{N}, \exists y = x \in \mathbb{N}$ such that $(x,y) \in R$ (F1) + \pfln F2 + \begin{subpf} + \pfln $\forall x \in \mathbb{N}$, let $y_1, y_2 \in \mathbb{N}$ + \pfln Suppose $(x,y_1) \in R \land (x, y_2) \in R$ + \pfln Then $y_1^2 = x^2$ and $y_2^2 = x^2$ (by defn of R) + \pfln Then $y_1^2 = y_2^2$ + \pfln Hence $y_1 = y_2$ (as $y_1,y_2 \in \mathbb{N} > 0$) + \end{subpf} + \end{numpf*} +\end{proof} + +\begin{proof} Proof of Injection: T06Q2 $f(x) = x+3$ + \begin{numpf*} + \pfln Let $x_1, x_2 \in \mathbb{R}$ such that $f(x_1) = f(x_2)$ + \pfln Then $x_1 + 3 = x_2 + 3$ + \pfln Then $x_1 = x_2$, therefore $f$ is injective + \end{numpf*} +\end{proof} + +\begin{proof} Proof of Surjection: T06Q2 $f(x) = x+3$ + \begin{numpf*} + \pfln Take any $y \in \mathbb{R}$ + \pfln Let $x = y - 3$ + \pfln Then $f(x) = f(y-3) = (y-3)+3 = y$, Therefore, $f$ is surjective + \end{numpf*} +\end{proof} +\begin{proof} Proof of Bijection via Inverse T06Q5: $f(x) = 12x+31$ + \begin{numpf*} + \pfln $\forall x,y \in \mathbb{Q}, y = 12x + 31 \iff x = (y-31)/12$ + \pfln define $g: \mathbb{Q} \to \mathbb{Q}$ by setting, $\forall y \in \mathbb{Q}, g(y) = (y-31)/12$ + \pfln Then whenever $x,y \in \mathbb{Q}, y=f(x) \iff x = g(y)$ + \pfln Thus $g$ is the inverse of $f$, hence $f$ is bijective (by Theorem 7.2.3) + \end{numpf*} +\end{proof} + + +\subsection*{Mathematical Induction} + +\begin{defn}[Sequence] Ordered Set with members called \textbf{terms}. May have infinite terms. In the form: $a_m, a_{m+1}, a_{m+2}, ...$ +\end{defn} + +\begin{defn}[Summation] + if $m$ and $n$ are integers and $m \leq n$, $\sum_{k=m}^{n}a_k$ is the sum of all terms $a_m, a_{m+1},...,a_n$ + + $k$ is the \textbf{index} of summation, $m$ is the \textbf{lower limit} and n the \textbf{upper limit} + + $\sum^{m}_{k=m}a_k = a_m$ and $\sum^{n}_{k=m}a_k = (\sum^{n-1}_{k=m}a_k) + a_n$ +\end{defn} + +\begin{defn}[Product] + if $m$ and $n$ are integers and $m \leq n$, $\prod_{k=m}^{n}a_k$ is the product of all terms $a_m, a_{m+1},...,a_n$ + + $\prod^{m}_{k=m}a_k = a_m$ and $\prod^{n}_{k=m}a_k = (\prod^{n-1}_{k=m}a_k) \cdot a_n$ +\end{defn} + +\begin{theorem}{5.1.1} Properties of Summations and Products + \begin{enumerate} + \item $\sum^{n}_{k=m}a_k + \sum^n_{k=m}b_k = \sum^n_{k=m}(a_k + b_k)$ + \item $c \cdot \sum^{n}_{k=m}a_k = \sum^n_{k=m}(c \cdot b_k)$ + \item $(\prod^{n}_{k=m}a_k) \cdot (\prod^n_{k=m}b_k) = \prod^n_{k=m}(a_k \cdot b_k)$ + \end{enumerate} +\end{theorem} + +\begin{defn} Arithmetic Sequence + $a_0, a_1,a_2$ is arithmetic if there is a constant d s.t. $a_k = a_{k-1}+d$ for all integers $k \geq 1$\\ + It follows that $a_n = a_0 + dn$ for all integers $n \geq 0$. $d$ is the common difference. $\sum^{n-1}_{k=0}a_k = \frac{n}{2}(2a_0 + (n-1)d)$ +\end{defn} +\begin{defn} Geometric Sequence + $a_0, a_1,a_2$ is arithmetic if there is a constant r s.t. $a_k = ra_{k-1}$ for all integers $k \geq 1$\\ + It follows that $a_n = a_0 r^n$ for all integers $n \geq 0$. $r$ is the common ratio. $\sum^{n-1}_{k=0}a_k = a_0(\frac{1-r^n}{1-r})$ +\end{defn} + +\begin{defn} Principle of Mathematical Induction + + To prove that "For all integers $n \geq a, P(n)$ is true" + \begin{itemize} + \item \textbf{Basis Step:} Show that $P(a)$ is true. + \item \textbf{Inductive Step: } Show that for all integers $k \geq a, P(k) \implies p(k+1)$. To perform this, suppose that P(k) is true, where k is a particular but arbitrarily chosen integer $k \geq a$ + \item Therefore $P(n)$ is true for all $n \in \mathbb{Z}^+$ + \end{itemize} +\end{defn} + +\begin{theorem}{5.2.2} Sum of first n integers: for all integers $n \geq 1, 1 + 2 + 3 + ... + n = \frac{n(n+1)}{2}$ \end{theorem} + +\begin{theorem}{5.2.3} Sum of a geometric sequence: for any real number $r \not = 1$, and any integers $n \geq 0, \sum^{n}_{i=0} r^i = \frac{r^{n+1}-1}{r-1}$ \end{theorem} + +\begin{propos}{5.3.1} For all integers $n \geq 0, 2^{2n}-1$ is divisible by 3 \end{propos} + +\begin{defn}[Strong induction (2PI)] If + \begin{itemize} + \item $P(a)$ holds + \item For every $k \geq a$, $(P(a) \land P(a+1) \land ... \land P(k)) \Rightarrow P(k+1)$ + \end{itemize} + Then $P(n)$ holds for all $n \geq a$ +\end{defn} + +\begin{defn}[Strong Induction Variant (2PI)] If + \begin{itemize} + \item $P(a), P(a+1),...,P(b)$ holds + \item For every $k \geq a, P(k) \Rightarrow P(k+b-a+1)$ + \end{itemize} + Then $P(n)$ holds for all $n \geq a$ +\end{defn} + +\begin{defn}[Well-Ordering Principle] + Every nonempty subset of $\mathbb{Z}_{\geq 0}$ has a smallest element +\end{defn} + +\begin{defn}[Recurrance Relation] for a sequence $a_0, a_1, a_2,...$ is a formula that relates each term $a_k$ to certain of its predecessors $a_{k-1},a_{k-2},...,a_{k-i}$, where $i$ is an integer with $k-i \geq 0$\\ If $i$ is a fixed integer, the \textbf{initial conditions} for such a recurrant relation specify the values of $a_0,a_1,a_2,...,a_{i-1}$\\ + If $i$ depends on $k$, the initial conditions specify the values of $a_0,a_1,a_2,...,a_{m}$, where $m$ is an integer with $m \geq 0$\\ + E.g. Fibonacci: $F_0 = 0; F_1 = 1; F_n = F_{n-1} +F_{n-2}$, for $n > 1$ +\end{defn} + +\begin{defn}[Recusively Defined Sets] + Let $S$ be a finite set with at least 1 element. A \textbf{string over} S is a finite sequence of elements from S. The elements of S are called \textbf{characters} of the string, and the length of a string is the number of characters it contains. The \textbf{null string over} S is defined to be the string with no characters (Length 0, $\varepsilon$).\\ + E.g. + \begin{enumerate} + \item Base: $()$ is in $P$ + \item Recusion: + \begin{enumerate} + \item If $E$ is in $P$, so is (E). + \item If $E$ and $F$ are in $P$, so is $EF$ + \end{enumerate} + \item Restriction: No configuration of parentheses are in $P$ other than those derived from 1 and 2 above. + \end{enumerate} +\end{defn} + +\begin{defn}[Recursive definition of a set $S$]\ + \begin{itemize} + \item (base clause) - Specify that certain elements, called \textbf{founders} are in $S$: if $c$ is a founder, then $c \in S$ + \item (recursion clause) - Specify certain functions, called \textbf{constructors} under which set $S$ is closed: if $f$ is a constructor and $x \in S$, then $f(x) \in S$ + \item (minimality clause) - Membership for $S$ can always be demonstrated by (infinitely many) successive applications of the clauses above + \end{itemize} +\end{defn} + +\subsection*{Mathematical Induction Proofs} + +\begin{proof}1PI Example: Given any set $A, |P(A)| = 2^n$, where P(A) is power set of A and |A| = n. + \begin{numpf} + \pfln For each $n \in \mathbb{N}$, let $P(n) \equiv (|P(A)| = 2^n$, where A is any n-element set + \pfln Basis Step: P(0) is true because $|P(\emptyset)| = |\{\emptyset\}| = 1 = 2^0$ as $P(\emptyset) = \{\emptyset\}$ and $|\emptyset| = 0$ + \pfln Induction Step: + \begin{subpf} + \pfln Let $k \in \mathbb{N}$ such that P(k) is true, i.e. $|P(X)| = 2^k$, where X is any k-element set + \pfln Let A be a $k+1$ element set. + \pfln Since $k \geq 0$, there is at least one element in A. Pick $z \in A$. + \pfln The subsets of A can be split to 2 groups: those that contain z and those that don't + \pfln Subsets that don't contain z are the same as the subsets of $A \setminus \{z\}$, which has a cardinality of k, and hence $|P(A\setminus \{z\})| = 2^k$ (by induction hypothesis) + \pfln Those subsets that contain z can be matched up one for one with those that do not contain z by unioninzing $\{z\}$ to the latter + \pfln Hence there is equal no of subsets that contain z and subsets that don't + \pfln Hence $|P(A)| = 2^k + 2^k = 2^{k+1}$ + \pfln Thus, P(k+1) is true + \end{subpf} + \pfln Therefore $\forall n \in \mathbb{N}, P(n)$ is true by MI + \end{numpf} + +\end{proof} + +\begin{proof}2PI example: Any integer greater than 1 is divisible by a prime number + \begin{numpf*} + \pfln Let $P(n) \equiv (n$ is divisible by a prime), for $n > 1$ + \pfln Basis Step: $P(2)$ is true since 2 is divisible by 2 + \pfln Inductive step To show that for all integers $k \geq 2$, if $P(i)$ is true, for all integers $i$ from 2 to $k$, then $P(k+1)$ is also true. + \begin{subpf} + \pfln Case 1 (k+1) is prime: in this case, K+1 is divisible by prime number, itself + \pfln Case 2 (k+1) is not prime: In this case, $k+1 = ab$, $a$ and $b$ are integers with $1 < a < k+1$ and $1 < b < k+1$ + \begin{subpf} + \pfln Thus, in particular, $2 \leq a \leq k$ and so by inductive hypothesis, a is divisble by prime number $p$ + \pfln In addition, because $k+1 = ab$, so $k+1$ is divisible by $a$ + \pfln By transitivity of divisibility, $k+1$ is divisible by prime $p$ + \end{subpf} + \end{subpf} + \pfln Therefore any integer greater than 1 is divisible by prime + \end{numpf*} +\end{proof} + +\begin{proof} 2PI for Sums: Prove that for any positive int n, if $a_1, a_2, ..., a_n$ and $b_1, b_2, ..., b_n$ are $\mathbb{R}$, then $\sum^n_{i=1}(a_i+b_i) = \sum^n_{i=1}(a_i) + \sum^n_{i=1}(b_i)$ + \begin{numpf*} + \pfln Let P(n) = $(\sum^n_{i=1}(a_i+b_i) = \sum^n_{i=1}(a_i) + \sum^n_{i=1}(b_i))$, for $n \geq 1$ + \pfln Basis Step: P(1) is true since $\sum^{1}_{i=1}(a_i+b_i) = a_i + b_i = \sum^{1}_{i=i}a_i + \sum^{1}_{i=i}b_i$ + \pfln Inductive Hypothesis: for some $k \geq 1$, $\sum^k_{i=1}(a_i+b_i) = \sum^k_{i=1}(a_i) + \sum^k_{i=1}(b_i)$ + \pfln Inductive Step = $\sum^{k+1}_{i=1}(a_i+b_i) = \sum^k_{i=1}(a_i+b_i) + (a_{k+1} + b_{k+1})$ (By defn of $\sum$)\\ + $ = \sum^{k}_{i=i}a_i + \sum^{k}_{i=i}b_i + (a_{k+1} + b_{k+1})$ (by inductive hypothesis) \\ + $ = \sum^{k}_{i=i}a_i + a_{k+1} + \sum^{k}_{i=i}b_i + b_{k+1}$ (by assoc and commutative law of algebra)\\ + $ = \sum^{k+1}_{i=i}a_i \sum^{k+1}_{i=i}b_i$ (By defn of $\sum$) + \pfln Therefore, P(k+1) is true, therefore P(n) is true for any positive integer n + \end{numpf*} +\end{proof} + +\subsection*{Cardinality} + +\begin{defn}[Pigeonhole Principle] + Let $A$ and $B$ be finite sets. If there is an injection $f: A \Rightarrow B$, then $|A| \leq |B|$\\ + Contrapositive: Let $m,n \in \mathbb{Z}^+$ with $m > n$. If $m$ pigeons are put into $n$ pigeonholes, there must be (at least) one pigeonhole with (at least) two pigeons. +\end{defn} +\begin{defn}[Dual Pigeonhole Principle] + Let $A$ and $B$ be finite sets. If there is an surjection $f: A \Rightarrow B$, then $|A| \geq |B|$\\ + Contrapositive: Let $m,n \in \mathbb{Z}^+$ with $m < n$. If $m$ pigeons are put into $n$ pigeonholes, there must be (at least) one pigeonhole with no pigeons. +\end{defn} + +\begin{defn}[Finite set and Infinite Set] + Let $\mathbb{Z}_n = \{1, 2, 3, ..., n\}$, the set of positive integers from 1 to $n$.\\ + A set $S$ is said to be \textbf{finite} iff $S$ is empty, or there exists a bijection from $S$ to $\mathbb{Z}_n$ for some $n \in \mathbb{Z}^+$\\ + A set $S$ is said to be \textbf{infinite} if it is not finite +\end{defn} + +\begin{defn}[Cardinality] + Cardinality of a finite set $S$, denoted $|S|$, is\\ + (i) 0 if $S = \emptyset$, or\\ + (ii) n if $f: S \Rightarrow Z_n$ is a bijection +\end{defn} + +\begin{theorem}{Equality of Cardinality of Finite Sets} Let A and B be any finite sets.\\ + $|A| = |B|$ iff there is a bijection $f: A \Rightarrow B$ +\end{theorem} + +\begin{defn}[Same Cardinality (Cantor)] + Given any 2 sets $A$ and $B$. A is said to have the same cardinality as $B$, $|A| = |B|$, iff there is a bijection $f: A \Rightarrow B$ +\end{defn} + +\begin{theorem}{7.4.1 Properties of Cardinality} Cardinality is an equivalence relation + \begin{itemize} + \item \textbf{Reflexive}: $|A| = |A|$ + \item \textbf{Symmetric}: $|A| = |B| \Rightarrow |B| = |A|$ + \item \textbf{Transitive}: $(|A| = |B|) \land (|B| = |C|) \Rightarrow |A| = |C|$ + \end{itemize} +\end{theorem} + +\begin{defn}[Cardinal Numbers] Define $\aleph_0 = |\mathbb{Z}^+|$ \end{defn} +\begin{defn}[Coutably Infinite] Set S is said to be countably infinite iff $|S| = \aleph_0$ \end{defn} +\begin{defn}[Coutably Infinite] Set S is said to be countable iff it is finite or countably infinite \end{defn} + +\begin{defn}[$\mathbb{Z}$ is countable] + $f(n) = \begin{cases} + n/2, & \text{if n is an even positive integer}\\ + -(n-1)/2, & \text{if n is an odd positive integer}\\ + \end{cases}$ +\end{defn} + +\begin{defn}[$\mathbb{Q}^+$ is countable] \end{defn} +\begin{defn}[$\mathbb{Z}^+ \times \mathbb{Z}^+$ is countable] \end{defn} + +\begin{theorem}[Cartesian Product] If sets $A$ and $B$ are both countably infinite, then so is $A \times B$.\end{theorem} +\begin{corollary}[General Cartesian Product] Given $n \geq 2$ countably infinite sets $A_1, A_2, ..., A_n$, cartesian product $A_1 \times A_2 \times ... \times A_n$ is also countably infinite \end{corollary} + +\begin{theorem}[Unions] Union of countably many countable sets is also countable. \end{theorem} + +\begin{propos}[9.1] Infinite set B is countable if and only if there is a sequence $b_0, b_1, ... \in B$ in which every element of $B$ appears exactly once \end{propos} +\begin{lemma}[9.2] Infinite set B is countable if and only if there is a sequence $b_0, b_1, ...$ in which every element of $B$ appears \end{lemma} + +\begin{theorem}{7.4.2}[Cantor] Set of real numbers between 0 and 1, $(0,1) = \{x\in \mathbb{R} | 0 < x < 1\}$ is uncountable \end{theorem} +\begin{theorem}{7.4.3} Any subset of any countable set is countable \end{theorem} +\begin{corollary}[7.4.4 (Contrapositive of 7.4.3)] Any set with an uncountable subset is uncountable\end{corollary} +\begin{propos}[9.3] Every infinite set has a countably infinite subset \end{propos} +\begin{lemma}[9.4 Union of countably infinite sets] Let A and B be countably infinite sets. Then $A \cup B$ is countable \end{lemma} + +\subsection*{Counting and Probability} +\begin{defn}[Sample Space] is set of all possible outcomes of random process or experiment \end{defn} +\begin{defn}[Event] is subset of sample space \end{defn} + +\begin{defn}[Probability of Event E in Sample Space S] $P(E) = \frac{|E|}{|S|}$, where |E| is number of outcomes in E and |S| is total number of outcomes \end{defn} + +\begin{theorem}{9.1.1}[Number of Elements in a List] + If $m$ and $n$ are integers and $m \leq n$, then there are $n-m+1$ integers from $m$ to $n$ inclusive. +\end{theorem} + +\begin{theorem}{9.2.1}[Multiplication/Product Rule] + If operation consists of k steps and 1st step performed in $n_1$ ways\\ + 2nd step in $n_2$ ways, $k^{th}$ step can be done in $n_k$ ways + + Entire Operation in $n_1 \times n_2 \times ... \times n_k$ ways. + + Should only be used for independent events +\end{theorem} + +\begin{theorem}{9.2.2}[Permutations] Number of permutations of a set with $n (n \geq 1)$ elements is $n!$ (Ordered selection) \end{theorem} + +\begin{defn}[R-Permutation] of a set of n elements is an ordered selection of $r$ elements taken from the set. Number of r-permutations of a set of n elements is $P(n,r)$ \end{defn} + +\begin{theorem}{9.2.3}[r-permutation from a set of n elements] If n and r are integers and $1 \geq r \geq n$, then number of r-permutations fo a set n is given by $P(n,r) = n(n-1)(n-2)...(n-r+1)= \frac{n!}{(n-r)!}$ \end{theorem} + +\begin{theorem}{9.3.1}[Addition/Sum Rule] Suppose a finite set $A$ equals the union of k distinct mutually disjoint subsets $A_1, A_2, ..., A_k$. Then $|A| = |A_1| + |A_2| + ... + |A_k|$ \end{theorem} + +\begin{theorem}{9.3.2}[The Difference Rule] if A is a finite set and $B \subseteq A$, then $|A \setminus B| = |A| - |B|$ \end{theorem} + +\begin{theorem}[Probability of complement of event] If S is a finite space and A is an event in S, then $P(\bar A) = 1 - P(A)$ \end{theorem} + +\begin{theorem}{9.3.3}[Inclusion/Exclusion Rule for 2/3 sets] + If A, B and C are finite sets, then $|A \cup B| = |A| + |B| - |A \cap B|$ and $|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|$ +\end{theorem} + +\begin{theorem}[Pigeonhole Principle (PHP)] Function from one finite set to a smaller finite set cannot be one-to-one. There must at least be 2 other elements in the domain that have same image in codomain \end{theorem} + +\begin{theorem}[Generalised PHP] For any function $f$ from finite set $X$ with $n$ elements to a finite set $Y$ with $m$ elements and for any positive integer $k$, if $k < n/m$, then there is some $y \in Y$ s.t. $y$ is the image of at least $k+1$ distinct elements of $X$. \end{theorem} + +\begin{theorem}[Generalised PHP (Contrapositive)] For any function $f$ from finite set $X$ with $n$ elements to a finite set $Y$ with $m$ elements and for any positive integer $k$, if for each $y \in Y, f^{-1}(\{y\})$ has at most $k$ elements, then $X$ has at most $km$ element; in other words $n \leq km$ \end{theorem} + +\begin{defn}[R-combination] Let $n$ and $r$ be non-negative intgers with $r \leq n$. An r-combination of a set of $n$ elements is a subset of $r$ of the $n$ elements. (Unordered selection) + + $n \choose r$, read "n choose r" denotes no of subsets of size $r$ that can be chosen from a set of $n$ elements. +\end{defn} + +\begin{defn}[Relationship between Permutation and Combination] + To get permutations of $\{0,1,2,3\}$, + \begin{enumerate} + \item Write the 2-combinations of $\{0, 1, 2, 3\}$ --> $(0,1), (0,2), (0,3),(1,2), (1,3),(2,3)$ + \item Order the 2 combination to obtain 2 permutations: $(0,1)$ and $(1,0)$, etc + \end{enumerate} + + Therefore, $P(n,r) = {n \choose r} \cdot r! = \frac{n!}{(n-r)!}$ +\end{defn} + +\begin{theorem}{9.5.1}[Formula for $n \choose r$] + $ = \frac{P(n, r)}{r!} = \frac{n!}{r!(n-r)!}$ +\end{theorem} + +\begin{theorem}{9.5.2}[Permutations of sets of indistinguishable objects] Suppose collection consists of $n$ objects of which + + $n_1, n_2, ..., n_k$ are of types \{1,2,...,k\} and indistinguishable from each other + + and suppose that $n_1 + n_2 + ... + n_k = n$. \\ + Then number of distinguisiable permutations = ${n \choose n_1}{n-n_1 \choose n_2}{n-n_1-n_2 \choose n_3}...{n-n_1-n_2-...-n_k-1 \choose n_k} = \frac{n!}{n_1!n_2!...n_k!}$ +\end{theorem} + +\begin{defn}[Example of 9.5.2] Order letters in MISSISSIPPI, how many orders are there? + + Subset of 4 positions for S = $11 \choose 4$, 4 positions for I = $7 \choose 4$, 2 positions for P = $3 \choose 2$, 1 positions for M = $1 \choose 1$, ${11 \choose 4}{7 \choose 4}{3 \choose 2}{1 \choose 1} = \frac{11!}{4!4!2!1!}$ +\end{defn} + +\begin{defn}[Multiset] An r-combination with repitition allowed, or multiset of size $r$, chosen from a set of $X$ of $n$ elements is an unordered selection of elements taken from $X$ with repetition allowed. If $X = \{x_1, x_2, ...,x_n\}$, we write an r-combination with repetition allowed as $[x_{i_1}, x_{i_2},..., x_{i_r}]$ where each $x_{i_j}$ is in $X$ and some of the $x_{i_j}$ may equal each other. \end{defn} + +\begin{theorem}{9.6.1}[Number of r-combinations with Repetition Allowed] (multisets of size r) that can be selected from a set of $n$ elements is ${r+n-1} \choose r$ = number of ways r objects can be selected from n categories of objects with repetitions allowed +\end{theorem} + +\begin{defn} Which formula to use? + \begin{tabular} { |l|c|c| } + \hline + & Order Matters & Order Does Not Matter \\ + \hline + Repetition & $n^k$ & $k+n-1 \choose k$ \\ + No Repetition & $P(n, k)$ & $n \choose k$ \\ + \hline + \end{tabular} +\end{defn} + +\begin{theorem}{9.7.1}[Pascals Formula] Let $n$ and $r$ be positive integers, $r \leq n$. Then ${n+1 \choose r} = {n \choose r-1} + {n \choose r}$ +\end{theorem} + +\begin{defn} Combinations + \begin{numpf} + \pfln For $0 \leq k \leq n, {n \choose k} = {n \choose n-k}$ + \pfln For $0 \leq k \leq n, k{n \choose k} = n{n-1 \choose k-1}$ + \end{numpf} +\end{defn} + +\begin{theorem}{9.7.2} Binomial Theorem + Given any real numbers $a$ and $b$ and any non-negative integer $n$,\\ + $(a+b)^n = \sum\limits^{n}_{k=0}{n \choose k} a^{n-k}b^k$ +\end{theorem} + +\begin{theorem}[Probability Axioms] P is a probability function from the set of all events in S. + \begin{enumerate} + \item $0 \geq P(A) \geq 1$ + \item $P(\emptyset) = 0$ and $P(S) = 1$ + \item If $A$ and $B$ are disjoint events, $(a \cap B = \emptyset)$, then $P(A \cup B) = P(A) + P(B)$ + \end{enumerate} +\end{theorem} + +\begin{defn}[Probability of General Union of 2 events] If A and B are events in S, then $P(A \cup B) = P(A) + P(B) - P(A \cap B)$ +\end{defn} + +\begin{defn}[Expected Value] $ = \sum^{n}_{k=1}a_kp_k = a_1p_1 + a_2p_2 + ... + a_np_n$, where a is outcome and p is probability of outcome \end{defn} + +\begin{defn}[Linearity of Expectation] Expected Value of sum of random variables x and y = $E[X + Y] = E[X] + E[Y]$, +\end{defn} + +\begin{defn}[Conditional Probability] of B given A, $P(B|A) = \frac{P(A \cap B)}{P(A)}$ \end{defn} + +\begin{theorem}{9.9.1}[Bayes' Theorem] + Sample space S is union of mutually disjoint events $B_1,B_2,...,B_n$ and + Suppose A is an event in S, and suppose $P(A) \not = 0$ and $P(B_i) \not = 0$. + + $P(B_k|A) = \frac{P(A|B_k) \cdot P(B_k)}{P(A|B_1)\cdot P(B_1)+ P(A|B_2)\cdot P(B_2) + ... + P(A|B_n)\cdot P(B_n)} = \frac{P(A|B_k)\cdot P(B_k)}{P(A)}$ +\end{theorem} + +\begin{defn}[Independent Event] If A and B are events in S, then A and B are independent, if and only if $P(A \cap B) = P(A) \cdot P(B)$ +\end{defn} + +\begin{defn}[Pairwise Independent and Mutually Independent] A, B and C are events in S. A, B, C are pairwise independent iff they satisfy conditions 1-3. Mutually independent iff all 4 conditions satisfied + + \begin{enumerate} + \item $P(A \cap B) = P(A) \cdot P(B)$ + \item $P(A \cap C) = P(A) \cdot P(C)$ + \item $P(B \cap C) = P(B) \cdot P(C)$ + \item $P(A \cap B \cap C) = P(A) \cdot P(B) \cdot P(C)$ + \end{enumerate} + +\end{defn} + +\subsection*{Graphs} + +\begin{defn}[Undirected Graph] 2 finite sets: Nonempty set of vertices V, set of edges, where each edge is associated with 1 or 2 vertices. \\ +Adjacent Vertice - 2 vertices connected by edge\\ +Adjacent Edges - 2 edges incident on same endpoint +\end{defn} + +\begin{defn}[Directed Graph] Same as undirected but has set of Directed Edges E, where each edge is an ordered pair of vertices \end{defn} + +\begin{defn}[Simple Graph] is undirected graph without any loops or parallel edges \end{defn} +\begin{defn}[Complete Graph] on n vertices, $n > 0, K_n$ is simple graph with n vertices and exactly 1 edge connecting each pair of distinct vertices (All of the nodes are directly connected) \end{defn} +\begin{defn}[Bipartite Graph] is simple graph whose vertices can be divided to 2 disjoint sets U and V such that every edge connects U to one in V \end{defn} + +\begin{defn}[Complete Bipartite Graph] is bipartite graph on 2 disjoint sets U and V such that every vertex in U connects to every in Vertex in V. If |U| = m, |V| = n, complete bipartite graph is $K_{m,n}$ \end{defn} + +\begin{defn}[Subgraph of a Graph] H is subgraph of G iff every vertex in H is in G, every edge in H is in G, every edge in H has same endpoints as G \end{defn} + +\begin{defn}[Degree of Vertex] Degree of v, $deg(v)$ = number of edges incident on v, with loops counted twice.\\ + Total degree of G, $deg(G)$ = sum of all degrees of all vertices in G +\end{defn} + +\begin{theorem}{10.1.1}[Handshake Theorem] If G is any graph, $deg(G) = deg(v_1) + deg(v_2) + ... + deg(v_n) = 2 \times |E|$, where E is the set of edges in G. \end{theorem} +\begin{corollary}{10.1.2} Total Degree of a graph is even \end{corollary} +\begin{propos}{10.1.3} There are even number of vertices of odd degree \end{propos} + +\begin{defn}[Indegree, Outdegree] G=(V,E) be directed graph and v a vertex of G.\\ +Indegree of v, $deg^-(v)$ is number of directed edges that end at v.\\ +Outdegree of v, $deg^+(v)$ is number of directed edges that originate from v.\\ +$\sum_{v\in V}deg^-(v) = \sum_{v\in V}^+(v) = |E|$ +\end{defn} +\begin{defn}[Walks] G be graph and v, w be vertices of G.\\ + \textbf{Walk from v to w} is an finite alternating sequence of vertices and edges of G. Walk has the form $v_0e_1v_1e_2...v_{n-1}e_nv_n$, where $v_0=v, v_n=w$. Number of edges n is length of walk (repeat edge/vertex)\\ + \textbf{Trivial Walk from v to v} - Single Vertex v\\ + \textbf{Trail from v to w} - walk without repeated edge\\ + \textbf{Path from v to w} - trail without repeated vertex and edges\\ + \textbf{Closed Walk} - Walk that starts and ends at same vertex (Repeated Vertex)\\ + \textbf{Circuit} - Closed Walk length at least 3 without repeated edge (Repeated Vertex)\\ + \textbf{Simple Circuit} - No repeated vertex except first and last\\ + \textbf{Cyclic} - Loops or cycle, otherwise \textbf{Acyclic} +\end{defn} + +\begin{defn}[Connecteddness] Vertices are connected iff walk from v to w. G is connected iff $\forall$ vertices $v, w \in V, \exists$ a walk from v to w. (All vertices are connected) +\end{defn} + +\begin{lemma}{10.2.1} Let G be a graph + \begin{enumerate} + \item If G is connected, any 2 distinct vertices are connected by path + \item If v and w are part of circuit in G, and one edge is removed, there exists trail from v to w in G + \item G is connected and G contains circuit, edge of circuit can be removed without disconnecting G + \end{enumerate} +\end{lemma} + +\begin{defn}[Connected Component] (Subgraph of largest possible size) + H is connected component iff + \begin{enumerate} + \item H is subgraph of G + \item H is connected + \item No connected subgraph of G has H as subgraph and contains vertices of edges not in H. + \end{enumerate} +\end{defn} + +\begin{defn}[Euler Circuit] Contains every vertex and traverses every edge exactly once (Can repeat vertices) \end{defn} +\begin{defn}[Euler Graph] Contains Euler Circuit \end{defn} + +\begin{theorem}{10.2.2} If graph has euler circuit, ever vertex of graph has positive even degree \end{theorem} +\begin{theorem}{10.2.2} (Contrapositive) If vertex has odd degree, then graph does not have Euler circuit \end{theorem} +\begin{theorem}{10.2.3} G is connected and degree of every vertex of G is even integer, then G has Euler circuit \end{theorem} +\begin{theorem}{10.2.4} G has euler circuit iff G is connected and every vertex has even degree \end{theorem} + +\begin{defn}[Euler Trail] passes through every vertex at least one and edge only once \end{defn} + +\begin{corollary}{10.2.5} Euler trail from v to w iff G is connected, v and w have odd degree and all other vertices have even degree \end{corollary} + +\begin{defn}[Hamiltonian Circuit] Simple circuit that includes every vertex of G (Every vertex appears once\end{defn} +\begin{defn}[Hamilton Graph] Contains Hamilton Circuit \end{defn} + +\begin{propos}{10.2.6} If G has Hamiltonian Circuit, G has subgraph H with the following + \begin{enumerate} + \item H contains every vertex of G + \item H is connected + \item H has same number of edges as vertices + \item Every vertex of H has degree 2 + \end{enumerate} +\end{propos} + +\begin{defn}[Adjacency Matrix] \textbf{A}$ = (a_{ij})$ over the set of non-negative integers s.t. $a_{ij} = $ number of arrows from $v_i$ to $v_j$ \end{defn} + +\begin{theorem}{10.3.2}[Number of walks of length n] A is adjacency matrix of G, the ij-th entry of $A^n = $ number of walks of length n from $v_i$ to $v_j$ \end{theorem} + +\begin{defn}[Isomorphic Graph] $G=(V_G,E_G)$ and $G' = (V_{G'}, E_{G'})$ + + G is isomorphic to $G'$, denoted $G \cong G'$, iff bijections $g: V_G \to V_{G'}$ and $h: E_G \to E_{G'}$, that preserve edge-edgepoint functions of G and G', in sense that $\forall v \in V_G, e \in E_G, v$ is an endpoint of $e \iff g(v)$ is and endpoint of $h(e)$ +\end{defn} + +\begin{theorem}{10.4.1}[Graph Isomorphism is Equivalence Relation] + S be set of graphs and let $\cong$ be relation of graph isomorphism on S. $\cong$ is equivalence relation on S +\end{theorem} + +\begin{defn}[Planar Graph] is graph that can be drawn on 2D plane without edges crossing +\end{defn} + +\begin{theorem}{Kuratowski's Theorem} Planar iff does not contain subgraph that is a subdivision of $K_5$ or complete bipartite $K_{3,3}$ \end{theorem} + +\begin{theorem}{Euler's Formula} For planar simple graph, let f be number of faces, $f = |E| - |V| + 2$ \end{theorem} + +\subsection*{Trees} + +\begin{defn}[Tree] \textbf{Tree} iff circuit free and connected\\ + \textbf{Trivial Tree} iff Single Vertex\\ +\textbf{Forest} iff circuit-free and not connected \end{defn} + +\begin{lemma}{10.5.1} Non trivial tree has at least one vertex of degree 1 \end{lemma} + +\begin{defn}[Terminal Vertex and Internal Vertex] Vertex of degree 1 in T is terminal vertex, vertex of degree greater than 1 is internal vertex \end{defn} + +\begin{theorem}{10.5.2} Any tree with n vertices $(n > 0)$ has $n-1$ edges \end{theorem} + +\begin{defn}E.g. Find all non-isomorphic trees with 4 vertices + 4 vertices means 3 edges = total degree of 6. So $deg(a) + deg(b) + deg(c) + deg(d) = 6$ +\end{defn} + +\begin{lemma}{10.5.3} G is connected graph, C is any circuit, one of the edges of C is removed from G, the graph remains connected \end{lemma} + +\begin{theorem}{10.5.4} G is a connected graph with n vertices and n-1 edges, G is a tree \end{theorem} + +\begin{defn}[Rooted Tree, Level, Height] \textbf{Rooted tree} is a tree with 1 vertex distinguished from others called root\\ + \textbf{Level} of a vertex is no of edges between it and root\\ + \textbf{Height} of a rooted tree is max level of any vertex of the tree +\end{defn} + +\begin{defn}[Child, Parent, Sibling, Ancestor, Descendant] + \textbf{Children} of v are all vertices that are adjacent to v and 1 level farther away from the root than v\\ + \textbf{Parent} if w is a child of v, then v is parent of w, and 2 vertices that are both children of same parent is \textbf{siblings} \\ + \textbf{Ancestor} if v lies on unique path between w and root, v is ancestor of w, and w is \textbf{descendant} of v\\ +\end{defn} + +\begin{defn}[Binary Tree, Full Binary Tree] + \textbf{Binary Tree} is rootred tree with every parent at most 2 children. Each child is either left child or right child.\\ + \textbf{Full Binary Tree} is where every parent has exactly 2 children +\end{defn} + +\begin{defn}[Left Subtree] Root is the left tree of v, vertices consist of left child o v and all its descendants, whose edges consist of all those edges of T that connect vertices of left subtree +\end{defn} + +\begin{theorem}{10.6.1}[Full Binary Tree Theorem] If T is full binary tree with k internal vertices, then T has total of $2k+1$ vertices, and has $k+1$ terminal vertices (leaves \end{theorem} + +\begin{theorem}{10.6.2} non-negative integers h, if T is any binary tree with height h and terminal vertices (leaves), then $t \leq 2^h$, $\log_2t \leq h$ +\end{theorem} + +\begin{defn}[Breadth-First Search] Starts at root, visit adjacent vertices, and then next level \end{defn} + +\begin{defn}Depth-First Search \\ + \textbf{Pre-order} Print root, traverse left, traverse right \\ + \textbf{In-order} Traverse Left, Print Root, Traverse right\\ + \textbf{post-order} Traverse Left, Traverse Right, Print Root +\end{defn} + +\begin{defn}[Spanning Tree] Subgraph that contains every vertex of G and is a tree \end{defn} + +\begin{propos}{10.7.1} + \begin{enumerate} + \item Every connected graph has a spanning tree + \item Any 2 spanning trees for a graph have same number of edges + \end{enumerate} +\end{propos} + +\begin{defn} Weighted Graph and Minimum Spanning Tree\\ + \textbf{Weighted Graph} is a graph for which each edge has a positive real number weight. Total weight = sum of weights of all edges\\ + \textbf{Minimum Spanning Tree} Least possible total weight compared to all other spanning trees for graph +\end{defn} + +\begin{theorem}{Kruskal's Algorithm}, Input is a connected weighted graph with n vertices + \begin{enumerate} + \item Initialise T to have all vertices of G and no edges + \item Let E be set of Edges in G and m = 0 + + \item While $(m < n - 1)$ + \begin{enumerate} + \item Find e in E of least weight + \item Delete e from E + \item If adding e to T does not create circuit, add e to T and set m = m + 1 + \end{enumerate} + \end{enumerate} +\end{theorem} + +\begin{theorem}{Prim's Algorithm}Input is a connected weighted graph with n vertices + \begin{enumerate} + \item Pick vertex v of G and let T be graph with this vertex only + \item Let V be set of all vertices of G except v + \item For i = 1 to n - 1 + \begin{enumerate} + \item Find edge $e$ of G s.t. e connects T to one vertice in V, e has the least weight of all edges connecteing T to V. Let w be endpoint of e in V + \item Add e and w to T, delete w from V + \end{enumerate} + \end{enumerate} +\end{theorem} + +\end{document} diff --git a/cheatsheets/cs1231s/midterms.pdf b/cheatsheets/cs1231s/midterms.pdf new file mode 100644 index 0000000..1458587 Binary files /dev/null and b/cheatsheets/cs1231s/midterms.pdf differ diff --git a/cheatsheets/cs1231s/midterms.tex b/cheatsheets/cs1231s/midterms.tex new file mode 100644 index 0000000..1c8211f --- /dev/null +++ b/cheatsheets/cs1231s/midterms.tex @@ -0,0 +1,917 @@ +\documentclass[a4paper]{article} +\usepackage{amsmath} +\usepackage{amsthm} +\usepackage{amssymb} + + +\usepackage[T1]{fontenc} +\usepackage{textcomp} +\usepackage{url} +% \usepackage{subcaption} +\usepackage{emptypage} +% \usepackage{multicol} +\usepackage{cancel} +\usepackage{mathtools} + +\usepackage{lscape} +\usepackage{pdflscape} + +\usepackage{float} + + +\usepackage{xifthen} +\usepackage[skip=10pt]{parskip} + +\usepackage{comment} +\usepackage[margin=0.5in]{geometry} +\setlength{\parindent}{0pt} + +\usepackage{1231num} + +\theoremstyle{definition} +\newtheorem*{defn}{Defn} + +\newtheorem*{propos}{Proposition} + +\renewcommand{\qedsymbol}{} + +\newtheorem{innertheorem}{Theorem} +\newenvironment{theorem}[1] + {\renewcommand\theinnertheorem{#1}\innertheorem} + {\endinnertheorem} + + +\author{Yadunand Prem} + +\title{Midterms Cheatsheet} + +\begin{document} + +\section{Math} + +\begin{defn}{Even and Odd Integers}\\ + n is even $\Leftrightarrow \exists$ an integer $k$ s.t. $n = 2k$\\ + n is odd $\Leftrightarrow \exists$ an integer $k$ s.t. $n = 2k + 1$ +\end{defn} + +\begin{defn}{Divisibility}\\ + $n$ and $d$ are integers and $d \not= 0$ \\ + $d | n \Leftrightarrow \exists k \in \mathbb{Z}$ s.t. $n = dk$ +\end{defn} + +\begin{theorem}{4.2.1} + Every Integer is a rational number +\end{theorem} + +\begin{theorem}{4.2.2} + The sum of any two rational numbers is rational +\end{theorem} + +\begin{theorem}{4.3.1} + For all $a, b \in \mathbb{Z}^+$, if $a | b$, then $a \leq b$ +\end{theorem} +\begin{theorem}{4.3.2} + Only divisors of $1$ are $1$ and $-1$ +\end{theorem} +\begin{theorem}{4.3.3} + $\forall a, b, c \in \mathbb{Z}$ if $a | b$, $b | c$, $a | c$ +\end{theorem} +\begin{theorem}{4.6.1} + There is no greatest integer +\end{theorem} +\begin{propos}{4.6.4} + For all integers $n$, if $n^2$ is even, then $n$ is even. +\end{propos} + +\begin{defn}{Rational} + $r$ is rational $\Leftrightarrow \exists a, b \in \mathbb{Z}$ s.t. $r = \frac{a}{b}$ and $b \not=0$ +\end{defn} +\begin{defn}{Fraction in lowest term:} +fraction $\frac{a}{b}$ is lowest term if largest $\mathbb{Z}$ that divies both $a$ and $b$ is 1 +\end{defn} + +\begin{theorem}{4.7.1} + $\sqrt{2}$ is irrational +\end{theorem} + + +\section{Logic of Combound Statements} + +\begin{theorem}{3.2.1} Negation of universal stmt + $\sim(\forall x \in D, P(x)) \equiv \exists x \in D$ s.t. $\sim P(x)$ +\end{theorem} +\begin{theorem}{3.2.1} Negation of existential stmt + $\sim(\exists x \in D$ s.t. $P(x)) \equiv \forall x \in D, \sim P(x)$ +\end{theorem} + +\begin{defn}{Contrapositive} + of $p \Rightarrow q \equiv \sim q \Rightarrow p$ +\end{defn} + +\begin{defn}{Converse} + of $p \Rightarrow q$ is $q \Rightarrow p$ +\end{defn} +\begin{defn}{Inverse} + of $p \Rightarrow q$ is $\sim p \Rightarrow \sim q$ +\end{defn} + +\begin{defn}{Only if:} + $p$ only if $q$ means $\sim q \Rightarrow \sim p \equiv p \Rightarrow q$ +\end{defn} + +\begin{defn}{Biconditional:} + $p \Leftrightarrow q \equiv (p \Rightarrow q) \land (q \Rightarrow p)$ +\end{defn} +\begin{defn} + $r$ is sufficient condition for $s$ means if $r$ then $s$, $r \Rightarrow s$ +\end{defn} +\begin{defn} + $r$ is necessary condition for $s$ means if $\sim r$ then $\sim s$, $s \Rightarrow r$ +\end{defn} + + +\begin{defn}{Proof by Contradiction}\\ + If you can show that the supposition that sttatement $p$ is false leads to a contradiction, then you can conclude that $p$ is true +\end{defn} + +\section{Methods of Proof} + +\begin{tabular} {|c|l|} + \hline + Statement & Proof Approach \\ + $\forall x \in D\ P(X)$ & Direct: Pick arbitrary x, prove P is true for that x. \\ + & Contradiction: Suppose not, i.e. $ \exists x(\sim p)$... Hence supposition $\sim p$ is false (P3) \\ + \hline + $\exists x \in D\ P(X)$ & Direct: Find x where P is true. \\ + & Contradiction: Suppose not, i.e. $\forall x (\sim p)$... Hence supposition $\sim p$ is false (P3) \\ + \hline + $P \Rightarrow Q$ & Direct: Assume P is true, prove Q \\ + & Contradiction: Assume P is true and Q is false, then derive contradiction \\ + & Contrapositive: Assume $\sim Q$, then prove $\sim P$ \\ + \hline + $P \Leftrightarrow Q$ & Prove both $P \Rightarrow Q$ and $Q \Rightarrow P$ \\ + \hline + $xRy$. Prove R is equivalence & Prove Reflexive, Symmetric and Transitive \\ + \hline + Reflexive & \\ + \hline + Symmetric & \\ + \hline + Antisymmetric & \\ + \hline + Transitive & \\ + \hline + + +\end{tabular} + +\begin{defn}{Proof by Contraposition}\\ + 1. Statement to be proved $\forall x \in D\ (P(x) \Rightarrow Q(x))$\\ + 2. Contrapositive Form: $\forall x \in D\ (\sim Q(x) \Rightarrow \sim P(x))$\\ + 3. Prove by direct proof\\ + 3.1 Suppose x is an element of D s.t. $Q(X)$ is false\\ + 3.2 Show that P(x) is false.\\ + 4. Therefore, original statement is true +\end{defn} + + +\section{Set Theory} + +\begin{defn}{Set: Unordered collection of objects}\\ + Order and duplicates don't matter +\end{defn} + +\begin{defn}{Membership of Set $\in$: } + If $S$ is set, $x \in S$ means $x$ is an element of $S$ +\end{defn} + +\begin{defn}{Cardinality of Set $|S|$: } + The number of elements in $S$ +\end{defn} + +Common Sets: + +$\mathbb{N}$ - Natural Numbers, $\{0, 1, 2\}$ + +$\mathbb{Z}$ - Integers + +$\mathbb{Q}$ - Rational + +$\mathbb{R}$ - Real + +$\mathbb{C}$ - Complex + +$\mathbb{Z}^\pm$ - Positive/Negative Integers + +\begin{defn}{Subset} + $A \subseteq B \Leftrightarrow$ Every element of $A$ is also an element of $B$\\ + $A \subseteq B \Leftrightarrow \forall x(x\in A \Rightarrow x \in B)$ +\end{defn} + +\begin{defn}{Proper Subset} + $A \subsetneq B \Leftrightarrow (A \subseteq B \land A \not = B)$ +\end{defn} + +\begin{theorem}{6.2.4} + An empty set is a subset of every set, i.e. $\emptyset \subseteq A$ for all sets $A$ +\end{theorem} + +\begin{defn}{Cartesian Product} + $A \times B = \{(a, b): a \in A \land b \in B\} $ +\end{defn} + +\begin{defn}{Set Equality} + $A = B \Leftrightarrow A \subseteq B \land B \subseteq A$ \\ + $A = B \Leftrightarrow \forall x (x \in A \Leftrightarrow x \in B)$ +\end{defn} + +\begin{defn}{Union:} + $A \cup B = \{x \in U: x \in A \lor x \in B\}$ +\end{defn} + +\begin{defn}{Intersection:} + $A \cap B = \{x \in U: x \in A \land x \in B\}$ +\end{defn} + +\begin{defn}{Difference:} + $B \setminus A = \{x \in U: x \in B \land x \not\in A\}$ +\end{defn} + +\begin{defn}{Disjoint:} + $A \cap B = \emptyset$ +\end{defn} + +\begin{theorem}{4.4.1} Quotient-Remainder + $n \in \mathbb{Z}, d \in \mathbb{Z}^+$\\ there exists unique integers q and r such that $n = dq + r$ and $0 \leq r < d$ +\end{theorem} + +\begin{defn}{Power Set:} + The set of all subsets of $A$, has $2^n$ elements. +\end{defn} + +\begin{theorem}{6.3.1} + Suppose $A$ is a finite set with $n$ elements, then $P(A)$ has $2^n$ elements. + $|P(A)| = 2^{|n|}$ +\end{theorem} + +\begin{defn}{Cartesian Product of $A_n$} + $= A_1 \times A_2 \times ... \times A_n = \{(a_1, a_2,...a_n): a_1 \in A_1 \land a_2 \in A_2...$ +\end{defn} + +\begin{theorem}{6.2.1} Subset Relations + \begin{numpf*} + \pfln Inclusion of Intersection: $A \cup B \subseteq A, A \cup B \subseteq B$ + \pfln Inclusion in Union $A \subseteq A \cup B, B \subseteq A \cup B$ + \pfln Transitive Property of Substs: $A \subseteq B \land B \subseteq C \Rightarrow A \subseteq C$ + \end{numpf*} +\end{theorem} + +\section{Relations} + +\begin{defn} Relation from A to B is a subset of $A \times B$\\ + Given an ordered pair$(x, y) \in A\times B$, $x$ is + related to y by $R$ is written $xRy \Leftrightarrow (x, y) \in R$ +\end{defn} + +\begin{defn} Domain, Co-domain, Range\\ + Let $A$ and $B$ be sets and $R$ be a relation from $A$ to $B$ + \begin{numpf*} + \pfln Domain of R: is set $\{a \in A: aRb$ for some $b \in B\}$ + \pfln Codomain of R: Set B + \pfln Range of R: is set $\{b \in B: aRb$ for some $a \in A\}$ + \end{numpf*} +\end{defn} + +\begin{defn} Inverse Relation\\ + Let $R$ be a relation from $A$ to $B$, + $R^{-1} = \{(y, x) \in B\times A: (x, y) \in R\}$\\ + $\forall x \in A, \forall y \in B ((y, x) \in R^{-1} \Leftrightarrow (x, y) \in R)$ +\end{defn} + +\begin{defn} + Relation on a Set $A$ is a relation from $A$ to $A$. +\end{defn} + +\begin{defn} Composition of Relations\\ + A, B and C be sets. $R \subseteq A \times B$ be a relation. $S \subset B \times C$ be relation. Composition of R with S, denoted $S \circ R$ is relation from A to C such that: \\ + $\forall x \in A, \forall z \in C(x S \circ R z \Leftrightarrow (\exists y \in B (xRy \land ySz)))$ +\end{defn} + +\begin{propos} Composition is Associative + $A, B, C, D$ be sets. $R \subseteq A \times B$, $S \subseteq B \times C$, $T \subseteq C \times D$\\ + $T \circ ( S \circ R) = T \circ S \circ R$ +\end{propos} + +\begin{propos} Inverse of Composition + $A, B, C$ be sets. $R \subseteq A \times B$, $S \subseteq B \times C$\\ + $(S \circ R)^{-1} = R^{-1} \circ S^{-1}$ +\end{propos} + +\begin{defn} \textbf{Reflexivity, Symmetry, Transitivity} + \begin{numpf*} + \pfln Reflexivity: $\forall x \in A (xRx)$ + \pfln Symmetry: $\forall x,y \in A (xRy \Rightarrow yRx)$ + \pfln Transitivity:$\forall x,y,z \in A (xRy \land yRz \Rightarrow xRz)$ + \end{numpf*} + Refer to proof 6 +\end{defn} + +\begin{defn} Transitive Closure\\ + Transitive closure of R is relation $R^t$ on A that satiesfies + \begin{numpf*} + \pfln $R^t$ is transitive + \pfln $R \subseteq R^t$ + \pfln If $S$ is any other transitive relation that contains $R$, then $R^t \subseteq S$ + \end{numpf*} +\end{defn} + +\begin{defn} Partition\\ + $P$ is partition of set A if + \begin{numpf*} + \pfln $P$ is a set of which all elements are non empty subsets of A, $\emptyset \not = S \subseteq A$ for all $S \in P$ + \pfln Every element of $A$ is in exactly on element of P, \\ + $\forall x \in A\ \exists S \in P (x \in S)$ and \\ + $\forall x \in A\ \exists S_1, S_2 \in P(x \in S_1 \land x \in S_2 \Rightarrow S_1 = S_2)$ + \end{numpf*} + OR $\forall x \in A\ \exists!S \in P(x \in S)$\\ + Elements of a partition are called components +\end{defn} + +\begin{defn} Relation Induced by a partition\\ + Given partition $P$ of $A$, the relation $R$ induced by partition: \\ + $\forall x, y \in A, xRy \Rightarrow \exists$ a component of $S$ of $P$ s.t. $x, y \in S$ +\end{defn} + +\begin{theorem}{8.3.1}[Relation Induced by a Partition] + Let $A$ be a set with a partition and let R be a relation induced by the partition. Then $R$ is reflexive, symmetric and transitive +\end{theorem} + +\begin{defn}[Equivalence Relation] + $A$ be set and $R$ be relation. $R$ is equivalence relation iff $R$ is reflexive, symmetric and transitive +\end{defn} + +\begin{defn} Equivalence Class\\ + Suppose $A$ is set and $\sim$ is equivalence relation on A. For each $A \in A$, equivalence class of $a$, denoted $[a]$ and called class of $a$ is set of all elements $x \in A$ s.t. $a\sim x$\\ + $[a]_{\sim} = \{x \in A: a \sim x \}$ +\end{defn} + +\begin{theorem}{8.3.4} The partition induced by an Equivalence Relation\\ + If $A$ is a set and $R$ is an equivalence relation on $A$, then distinct equivalence classes of $R$ form a partition of $A$; that is, the union of the equivalence classes is all of $A$, and the intersection of any 2 disctinct classes is empty. +\end{theorem} + +\begin{defn} Congruence\\ + Let $a, b \in \mathbb{Z}$ and $n \in \mathbb{Z}^+$. Then $a$ is congruent to $b$ modulo $n$ iff $a - b = nk$, for some $k \in \mathbb{Z}$. In other words, $n | (a - b)$. We write $a \equiv b (\text{mod}\ n)$ +\end{defn} + +\begin{defn} Set of equivalence classes\\ + Let $A$ be set and $\sim$ be an equivalence relation on $A$. Denote by $A/\sim$, the set of all equivalence classes with respect to $\sim$, i.e. + + $A/\sim = \{[x]_\sim: x \in A\}$ +\end{defn} + +\begin{theorem}{Equivalence Classes} form a partition + Let $\sim$ be an equiv. relation on $A$. Then $A/\sim$ is a partition of A. +\end{theorem} + +\begin{defn}[Antisymmetry] + $R$ is antisymmetric iff $\forall x, y \in A(xRy \land yRx \Rightarrow x = y)$ \textit{(DOES NOT IMPLY NOT SYMMETRIC)} +\end{defn} + +\begin{defn}[Partial Order Relation] + $R$ is Partial Order iff R is \textit{reflexive}, \textit{antisymmetric} and \textit{transitive}. +\end{defn} + +\begin{defn}{Partially Ordered Set} + Set A is called poset with respect to partial order relation $R$ on $A$, denoted by $(A, R)$ (Proof 7) +\end{defn} + +\begin{defn}{$x \preccurlyeq y$} + is used as a general partial order relation notation +\end{defn} + +\begin{defn}[Hasse Diagram] + Let $\preccurlyeq$ be a partial order on set $A$. Hasse diagram satisfies the following condition for all distinct $x, y, m \in A$ \\ + If $x \preccurlyeq y$ and no $m \in A$ is s.t. $x \preccurlyeq m \preccurlyeq y$, then x is placed below y with a line joining them, else no line joins $x$ and $y$. +\end{defn} + +\begin{defn}[Comparability] + $a, b \in A$ are comparable iff $a \preccurlyeq b$ or $b \preccurlyeq a$. Otherwise, they are \textbf{noncomparable} +\end{defn} + +\begin{defn}[Maximal, Minimal, Largest Smallest] + Set $A$ be partially ordered w.r.t. a relation $\preccurlyeq$ and $c \in A$ + \begin{numpf} + \pfln c is maximal element of $A$ iff $\forall x \in A$, either $x \preccurlyeq c$ or $x$ and $c$ are non-comparable. OR $\forall x in A(c \preccurlyeq x \Rightarrow c = x)$ + \pfln c is minimal element of $A$ iff $\forall x \in A$, either $c \preccurlyeq x$ or $x$ and $c$ are non-comparable. OR $\forall x in A(x \preccurlyeq c \Rightarrow c = x)$ + \pfln c is largest element of $A$ iff $\forall x \in A (x \preccurlyeq c)$ + \pfln c is smallest element of $A$ iff $\forall x \in A (c \preccurlyeq x)$ + \end{numpf} +\end{defn} + +\begin{propos} A smallest element is minimal\\ + Consider a partial order $\preccurlyeq$ on set $A$. Any smallest element is minimal. + \begin{numpf} + \pfln Let $c$ be smallest elemnt + \pfln Take any $x \in A$ s.t. $x \preccurlyeq c$ + \pfln By smallestness, we know $c \preccurlyeq x$ too. + \pfln So $c = x$ by antisymmetry + \end{numpf} +\end{propos} + +\begin{defn}[Total Order Relations] All elements of the set are comparable\\ + R is total order iff $R$ is a partial order and $\forall x, y \in A (xRy \lor yRx)$ +\end{defn} + +\begin{defn}[Linearization of a partial order] + Let $\preccurlyeq$ be a partial order on set $A$. A linearization of $\preccurlyeq$ is a total order $\preccurlyeq *$ on $A$ s.t. $\forall x, y \in A (x \preccurlyeq y \Rightarrow x \preccurlyeq *\ y)$ +\end{defn} + +\begin{defn}[Kahn's Algorithm] + Input: A finite set $A$ and partial order $\preccurlyeq$ on $A$ + \begin{numpf} + \pfln Set $A_0 := A$ and $i := 0$ + \pfln Repeat until $A_i = \emptyset$ + \begin{subpf} + \pfln Find minimal element $c_i$ of $A_i$ wrt $\preccurlyeq$ + \pfln Set $A_{i+1} = A_i \setminus {c_i}$ + \pfln Set $i = i+1$ + \end{subpf} + \end{numpf} + + Output: A linearization $\preccurlyeq *$ of $\preccurlyeq$ defined by setting, for all indicies $i, j$\\ $c_i \preccurlyeq*\ c_j \Leftrightarrow i \leq j$ +\end{defn} + +\begin{defn}[Well ordered set] Let $\preccurlyeq$ be a total order on set $A$. $A$ is well ordered iff every nonempty subset of A contains a smallest element. OR\\ + $\forall S \in P(A), S \not = \emptyset \Rightarrow (\exists x \in S \forall y \in S (x \preccurlyeq y))$ E.g. $(\mathbb{N}, \leq)$ is well ordered but $(\mathbb{Z}, \leq)$ is not as there is no smallest integer (Theorem 4.6.1) + +\end{defn} + +\section{Proofs} + +\begin{proof} [\proofname\ L1S28] +Prove that the product of two consecutive odd numbers is always odd. +\begin{numpf*} + \pfln Let $a$ and $b$ be two consecutive odd numbers + \begin{subpf*} + \pfln Without loss of generality, assume that $a < b$, hence $b = a + 2$ + \pfln Now, $a = 2k+1$ (by defn of odd numbers) + \pfln Similarly, $b = a + 2 = 2k + 3$ + \pfln Therefore, $ab = (2k+1)(2k+3) = (4k^2 + 6k) + (2k + 3) = 4k^2 + 8k + 3 = 2(2k^2 + 4k + 1) + 1$ (by Basic Algebra) + \pfln Let $m = (2k^2 + 4k + 1)$ which is an integer (by closure of integers under $\times$ and $+$) + \pfln Then $ab = 2m + 1$ which is odd (by defn of odd numbers) + \end{subpf*} + \pfln Therefore, the product of two consecutive odd numbers is always odd. +\end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ L4S16] Sum of 2 even $\mathbb{Z}$ is even + \begin{numpf*} + \pfln Let m and n be two particular but arbitrarily chosen even intergers + \begin{subpf*} + \pfln Then $m = 2r$ and $n = 2s$ for some $\mathbb{Z}$ $r$ and $s$ (by defn of even number) + \pfln $m + n = 2r + 2s = 2(r+s)$ (by basic algebra) + \pfln 2(r+s) is an integer(closure of int under $\times$ and $+$) and an even number (by defn of even number) + \pfln Hence $m+n$ is an even number + \end{subpf*} + \pfln Therefore sum of any two even integers is even + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T 4.6.1] There is no greatest integer (Contradiction) + \begin{numpf*} + \pfln Suppose not, i.e. there is a greatest intger + \begin{subpf*} + \pfln Lets call this greatest integer g, and $g \geq n$ for all integers n + \pfln Let $G = g + 1$ + \pfln Now, $G$ is an integer (closure of integers under $+$) and $G > g$ + \pfln Hence, g is not the greatest integer, contradicting 1.1 + \end{subpf*} + \pfln Hence, the supposition that there is a greatest integer is false. + \pfln Therefore there is no greatest integer + \end{numpf*} +\end{proof} +\begin{proof}[\proofname\ L5S19] L5S19 Two sets are equal + \begin{numpf*} + \pfln Let sets $X$ and $Y$ be given. To prove $X$ = $Y$ + \pfln ($\subseteq$) Prove $X \subseteq Y$ + \pfln ($\supseteq$) Prove $X \supseteq Y$ + \pfln From (2) and (3), we can conclude that $X = Y$ + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ L5S22] L5S22 $\{x \in Z: x^2 = 1\} = \{1, -1\}$ + \begin{numpf*} + \pfln $\rightarrow$ + \begin{subpf*} + \pfln Take any $z \in \{x \in \mathbb{Z} : x^2 = 1\}$ + \pfln Then $z \in \mathbb{Z}$ and $z^2 = 1$ + \pfln So, $z^2 -1 = (z-1)(z+1) = 0$ (by basic algebra) + \pfln $\therefore$ $z-1 = 0$ or $z +1 = 0$ + \pfln $\therefore$ $z = 1$ or $z = -1$ + \pfln So, $z \in \{1, -1\}$ + \end{subpf*} + \pfln $\leftarrow$ + \begin{subpf*} + \pfln Take any $z \in \{1, -1\}$ + \pfln Then $z = 1$ or $z=-1$ + \pfln In either case, we have $z \in \mathbb{Z}$ and $z^2 = 1$ + \pfln So, $z \in \{x \in \mathbb{Z} : x^2 = 1\}$ + \end{subpf*} + \pfln Therefore, $\{x \in Z: x^2 = 1\} = \{1, -1\}$ (from (1) and (2)) + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ L6S27] $\forall x,y \in \mathbb{Z} (xRy \Leftrightarrow 3 | (x-y))$ is reflexive, symmetric, transitive + \begin{numpf*} + \pfln Proof of Reflexivity + \begin{subpf*} + \pfln Let $a$ be an arbitrarily chosen integer. + \pfln Now $a - a = 0$ + \pfln $3 | 0 $(since $ 0 = 3 \cdot 0)$, hence $3 |(a - a)$ + \pfln Therefore $aRa$ (by defn of R) + \end{subpf*} + \pfln Proof of Symmetry + \begin{subpf*} + \pfln Let a, b be arbitrarily chosen integers + \pfln Then $3|(a-b)$ (by defn of R), hence $a-b = 3k$ for some integer k (by defn of divisibility) + \pfln Multiplying both sides by $-1$ gives $b-a = 3(-k)$ + \pfln Since $-k$ is an integer, $3 | (b-a)$ (by defn of divisibility) + \pfln Therefore, $aRb \Rightarrow bRa$ (by defn of R) + \end{subpf*} + \pfln Proof of Transitivity + \begin{subpf*} + \pfln Let a, b, c be arbitrarily chosen integers + \pfln Then, $3 | (a - b)$ and $3 | (b - c)$ (by defn of R), hence $a-b = 3r$ and $b-c = 3s$ (by defn of divisiblity) + \pfln Adding both equations gives $a - c = 3r + 3s$ + \pfln Since $r+s$ is an integer, $3 | (a - c)$ (by defn of divisiblity) + \pfln Therefore $aRb \land bRc \Rightarrow aRc$ (by defn of R) + \end{subpf*} + \end{numpf*} +\end{proof} + +\begin{proof}[Lemma Equivalence Class L6S47] Let $\sim$ be an equivalence relation on $A$. The following are equivalent for all $x, y \in A$ (i) $x\sim y$, (ii) $[x] = [y]$, (iii) $[x] \cap [y] \not = \emptyset$ + \begin{numpf*} + \pfln $x \sim y \Rightarrow [x] = [y]$ + \begin{subpf*} + \pfln Suppose $x \sim y$ + \pfln Then $y \sim x$ (by symmetry) + \pfln For every $z \in [x]$ + \begin{subpf*} + \pfln $x \sim z$ (by defn of x) + \pfln $\therefore y \sim z$ (by transitivity of $y\sim x$) + \pfln $\therefore z \in [y]$ (by defn of $[y]$) + \end{subpf*} + \pfln This shows $[x] \subseteq [y]$ + \pfln Switching roles of $x$ and $y$, we can also see that $[y] \subseteq [x]$ + \pfln Therefore, $[x] = [y]$ + \end{subpf*} + \pfln $[x] = [y] \Rightarrow [x] \cap [y] \not = \emptyset$ + \begin{subpf*} + \pfln Suppose $[x] = [y]$ + \pfln Then $[x] \cap [y] = [x]$ (by idempotent law for $\cap$) + \pfln However, we know $x\sim x$ (by reflexivity of $\sim$) + \pfln This shows $x \in [x] = [x] \cap [y]$ (by defn of [x] and (2.2)) + \pfln Therefore $[x] \cap [y] \not = \emptyset$ + \end{subpf*} + \pfln $[x] \cap [y] \not = \emptyset \Rightarrow x \sim y$ + \begin{subpf*} + \pfln Suppose $[x] \cap [y] \not = \emptyset$ + \pfln Take $z \in [x] \cap [y]$ + \pfln Then $z \in [x]$ and $z \in [y]$ (by defn of $\cap$) + \pfln Then $x \sim z$ and $y \sim z$ (by defn of $[x]$ and $[y]$) + \pfln $y \sim z$ implies $z \sim y$ (by defn of symmetry) + \pfln Therefore, $x \sim y$ (by transitivity) + \end{subpf*} + \end{numpf*} +\end{proof} + +\begin{proof}[Proposition L6S54] Congruence-mod $n$ is an equivalence relation on $\mathbb{Z}$ for every $n \in \mathbb{Z}^+$ + \begin{numpf*} + \pfln (Reflexivity) For all $a \in \mathbb{Z}$ + \begin{subpf*} + \pfln $a - a = 0 = n \times 0$ + \pfln So $a \equiv a (\text{mod}\ n)$ (by defn of congruence) + \end{subpf*} + \pfln (Symmetry) + \begin{subpf*} + \pfln Let $a, b \in \mathbb{Z}$ s.t. $a \equiv a (\text{mod}\ n)$ + \pfln Then there is a $k \in \mathbb{Z}$ s.t. $a - b = nk$ + \pfln Then $b - a = -(a - b) = -nk = n(-k)$ + \pfln $-k \in \mathbb{Z}$ (by closure of integers under $\times$), so $b \equiv a (\text{mod}\ n)$ (by defn of congruence) + \end{subpf*} + \pfln (Transitivity) + \begin{subpf*} + \pfln Let $a, b,c \in \mathbb{Z}$ s.t. $a \equiv a (\text{mod}\ n)$ and $b \equiv c (\text{mod}\ n)$ + \pfln Then there is a $k,l \in \mathbb{Z}$ s.t. $a - b = nk$ and $b - c = nl$ + \pfln Then $a - c = (a - b) + (b - c) = nk + nl = n(k + 1)$ + \pfln $k + l \in \mathbb{Z}$ (by closure of integers under $+$), so $a \equiv c (\text{mod}\ n)$ (by defn of congruence) + \end{subpf*} + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ L6S69] $\forall a, b \in \mathbb{Z}^+, \forall a | b \Leftrightarrow b = ka$ for some integer $k$. Prove $|$ is a partial order relation on $A$ + \begin{numpf*} + \pfln $|$ is reflexive: Suppose $a \in A$. Then $a = 1 \dot a$, so $a|a$ (by defn of divisiblity) + \pfln $|$ is antisymmetric + \begin{subpf*} + \pfln Suppose $a, b \in \mathbb{Z}^+$ such that $aRb$ and $bRa$ + \pfln Then $b = ra$ and $a = sb$ for some integers $r$ and $s$ (by defn of divides). It follows that $b = ra = r(sb)$ + \pfln Dividing both sides by $b$ gives $1 = rs$ + \pfln Only product of two positive integers that equals 1 is $1 \dot 1$. + \pfln Thus $r = s = 1$, and so $a = sb = 1 \dot b = b$ + \pfln Therefore, $|$ is antisymmetric + \end{subpf*} + OR + \begin{subpf*} + \pfln Suppose $a, b \in \mathbb{Z}^+$ such that $a|b$ and $b|a$ + \pfln then $a \leq b$ and $b \leq a$ (by theorem 4.3.1) + \pfln So $a = b$ + \end{subpf*} + \pfln $|$ is transitive: Show that $\forall a, b, c \in A, a|b \land b|c \Rightarrow a |c)$ (theorem 4.3.3) + \end{numpf*} + +\end{proof} + + +\begin{proof}[\proofname\ T01Q9] The product of any two odd integers is an odd integer + \begin{numpf*} + \pfln Take any 2 odd numbers $a$ and $b$ + \pfln Then $a = 2k+1$ and $b = 2p + 1$ for $k,p \in Z$ (by defn of odd number) + \pfln Then $a\cdot b = (2k+1)(2p+1) = (4kp + 2k) + (2p + 1) = 2(2kp + p + k) +1$ (by defn of odd number) + \pfln Let $q = 2kp + p +k$ which is an integer (by closure of int under $+$ and $\times$ + \pfln Then nm = 2q + 1 which is odd (by defn of odd numbers) + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T01Q10] Let $n$ be an integer. Then $n^2$ is odd iff $n$ is odd + \begin{numpf*} + \pfln Proof By Contraposition, that is "if n is even, $n^2$ is even $(\Rightarrow)$ + \begin{subpf*} + \pfln Suppose $n$ is even. + \pfln Then $\exists k \in \mathbb{Z}$ s.t. $n = 2k$ (by defn of even integers) + \pfln $n^2 = (2k)^2 = 4k^2 = 2(2k^2)$ + \pfln Hence, $n^2$ = 2p, where $p = 2k^2 \in \mathbb{Z}$ (by closure of integers under $\times$) + \pfln Therefore, $n^2$ is even and this proves that if $n^2$ is odd, $n$ is odd. + \end{subpf*} + \pfln If $n$ is odd, then $n \times n = n^2$ is odd (T01Q9) + \pfln Therefore $n^2$ is odd if and only if $n$ is odd. + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T02Q3] Rational numbers are closed under addition + \begin{numpf*} + \pfln Let r and s be rational numbers + \pfln $\exists a,b,c,d \in \mathbb{Z}$ s.t. $r =\frac{a}{b}, s = \frac{c}{d}$ and $b \not = 0, d \not = 0$ (by defn of rational numbers) + \pfln Hence $r + s = \frac{a}{b} + \frac{c}{d} = \frac{ad + bc}{bd}$ (by basic algebra) + \pfln $ad + bd \in Z$ and $bd \in Z$ (closure of integers under $+$ and $\times$) + \pfln $bd \not = 0$ since $b \not = 0, d \not = 0$ + \pfln Hence $r+s$ is rational, therefore rational numbers are closed under addition + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T02Q10] if $n$ is a product of 2 positive integers $a$ and $b$, then $a \leq n^{1/2}$ or $b \leq n^{1/2}$ + \begin{numpf*} + \pfln Proof by contraposition, that is if $a > n^{1/2}$ and $b > n^{1/2}$, then $n$ is not a product of $a$ and $b$ + \pfln Suppose $a > n^{1/2}$ and $b > n^{1/2}$, then $ab > n^{1/2} \cdot n^{1/2} = n$ (by Appendix A T27) + \pfln Since $ab \not = n$, the contrapositive statement is true + \end{numpf*} + or by contradiction + \begin{numpf*} + \pfln Proof by contradiction, that is $n = ab$ and $a > n^{1/2}$ and $b > n^{1/2}$ + \pfln Since $a > n^{1/2}$ and $b > n^{1/2}$, then $ab > n^{1/2} \cdot n^{1/2} = n$ (by Appendix A T27) + \pfln This contradicts $n = ab$. Therefore original statement is true + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T03Q04] Let $A = \{2n+1: n \in \mathbb{Z}\}$ and $B = \{2n-5: n \in \mathbb{Z}\}$. Is $A$ = $B$? + \begin{numpf*} + \pfln $\subseteq$ + \begin{subpf} + \pfln Let $a \in A$, and $a = 2n + 1, n \in \mathbb{Z}$ + \pfln Then $a = 2n + 1 = 2 (n+3) - 5$ + \pfln $n + 3 \in Z$ (by closure of int under $+$) + \pfln Therefore, $a \in B$ (by defn of B) + \end{subpf} + \pfln $\supseteq$ + \begin{subpf} + \pfln Let $b \in A$, and $b = 2n - 5, n \in \mathbb{Z}$ + \pfln Then $b = 2n - 5 = 2 (n-3) + 1$ + \pfln $n - 3 \in Z$ (by closure of int under $-$) + \pfln Therefore, $b \in A$ (by defn of B) + \end{subpf} + \pfln Therefore, A = B + \end{numpf*} +\end{proof} +\begin{proof}[\proofname\ T03Q05] Prove $\forall A, B, C, A \cap (B \setminus C) = (A \cap B) \setminus C$ + \begin{numpf*} + \pfln $A \cap (B \setminus C) = \{x: x \in A \land x \in (B \setminus C) \}$ (by defn of $\cap$) + \pfln $ = \{x: x \in A \land (x \in B \land x \not \in C) \}$ (by defn of $\setminus$) + \pfln $ = \{x: x \in (A \land x \in B) \land x \not \in C \}$ (by associativity of $\land$) + \pfln $ = \{x: x \in (A \cap B) \land x \not \in C \}$ (by defn of $\cap$) + \pfln $ = \{x: x \in (A \cap B) \setminus C$ (by defn of $\setminus$) + \end{numpf*} +\end{proof} +\begin{proof}[\proofname\ T03Q05] Prove $\forall A, B, C, A \cap (B \setminus C) = (A \cap B) \setminus C$ + \begin{numpf*} + \pfln $A \cap (B \setminus C) = \{x: x \in A \land x \in (B \setminus C) \}$ (by defn of $\cap$) + \pfln $ = \{x: x \in A \land (x \in B \land x \not \in C) \}$ (by defn of $\setminus$) + \pfln $ = \{x: x \in (A \land x \in B) \land x \not \in C \}$ (by associativity of $\land$) + \pfln $ = \{x: x \in (A \cap B) \land x \not \in C \}$ (by defn of $\cap$) + \pfln $ = \{x: x \in (A \cap B) \setminus C$ (by defn of $\setminus$) + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname T03Q8] Let $A$ and $B$ be set. Show that $A \subseteq B$ if and only if $A \cup B = B$\\ + To show $A \cup B = B$, we need to show $A \cup B \subseteq B$ and $B \subseteq A \cup B$ + \begin{numpf*} + \pfln $\implies$ + \begin{subpf} + \pfln Suppose $A \subseteq B$ + \pfln (Show $A \cup B \subseteq B$) + \begin{subpf} + \pfln Let $z \in A \cup B$ + \pfln Then $z \in A$ or $z \in B$ (by defn of $\cup$) + \pfln Case 1: Suppose $z \in A$, then $Z \in B$ as $A \subseteq B$ line (1.1) + \pfln Case 2: Suppose $z \in B$, then $z \in B$. We have $z\in B$ in either case + \end{subpf} + \pfln (Show $A \cup B \supseteq B$) + \begin{subpf} + \pfln Let $z \in B$ + \pfln Then $z \in A$ or $z \in B$ (by generalization) + \pfln So $z \in A \cup B$ (by defn of $\cup$) + \end{subpf} + \pfln Therefore $A \cup B = B$ + \end{subpf} + \pfln $\impliedby$ + \begin{subpf} + \pfln Suppose $A \cup B = B$ + \pfln Let $z \in A$ + \begin{subpf} + \pfln Then $z \in A$ or $z \in B$ (by generalization) + \pfln So $z \in A \cup B$ (by defn of $\cup$) + \pfln So $z \in B$ since $A \cup B = B$ (2.1) + \end{subpf} + \pfln Therefore $A \subseteq B$ + \end{subpf} + \pfln Therefore, $A \subseteq B$ if and only iff $A \cup B = B$ + \end{numpf*} +\end{proof} + +\begin{proof}[\proofname\ T04Q05] Relation $S = \{(m,n) \in \mathbb{Z}^2: m^3 + n^3 \text{is even} \}$, Proof $S \circ S = S$ + \begin{numpf*} + \pfln ($\subseteq$) Suppose $(x, z) \in S \circ S$ + \begin{subpf} + \pfln Then $(x, y) \in S$ and $(y, z) \in S$ for some $y \in Z$ (defn of composition of relations) + \pfln So $x^3 + y^3$ is even and $y^3 + z^3$ is even + \pfln This implies that $x^3 + 2y^3 + z^3$ is even + \pfln This implies that $x^3 + z^3$ is even as $2y^3$ is even + \pfln Therefore, $(x, z) \in S$ (by defn of $S$) + \end{subpf} + \pfln ($\supseteq$) Suppose $(x,z) \in S$ + \begin{subpf} + \pfln Then $x^3 + z^3$ is even (by defn of S) + \pfln Case 1: $x^3$ is odd. + \begin{subpf} + \pfln Then $z^3$ is also odd. + \pfln This implies that $x^3 + 1^3$ is even and $1^3 + z^3$ is even + \pfln Thus, $(x,1) \in S$ and $(1,z) \in S$ (by defn of S) + \pfln So, $(x,z) \in S \circ S$ + \end{subpf} + \pfln Case 2: $x^3$ is even. + \begin{subpf} + \pfln Then $z^3$ is also even. + \pfln This implies that $x^3 + 0^3$ is even and $0^3 + z^3$ is even + \pfln Thus, $(x,0) \in S$ and $(0,z) \in S$ (by defn of S) + \pfln So, $(x,z) \in S \circ S$ + \end{subpf} + \pfln In all cases, $(x,z) \in S \circ S$ + \end{subpf} + OR + \pfln ($\supseteq$) Suppose $(x,z) \in S$ + \begin{subpf} + \pfln Note that $(x, x) \in S$ as $x^3 + x^3$ is even + \pfln Since $(x, x) \in S$ and $(x,z) \in S$, we have $(x, z) \in S \circ S$ (by defn of composition of relations) + \end{subpf} + \end{numpf*} + +\end{proof} + +\begin{proof} $R$ is asymmetric if and only if $R$ is antisymmetric and irreflexive. + \begin{numpf} + \pfln $\implies$ + \begin{subpf} + \pfln R is irreflexive (R is irreflexive $\implies$ R is antisymmetric and irreflexive) + \begin{subpf} + \pfln Let $x \in A$ s.t. $xRx \implies x \not R x$ (R is Asymmetric) + \pfln Since $x\not R x$, R is irreflexive (by defn of irreflexive) + \end{subpf} + \end{subpf} + \begin{subpf} + \pfln R is antisymmetric (Tutorial Qn 6c) + \end{subpf} + \pfln $\impliedby$ (R is antisymmetric and irreflexive $\implies$ asymmetry) + \begin{subpf} + \pfln Let $x, y \in A$, s.t. xRy is antisymmetric and irreflexive + \pfln There is 2 cases to consider, $x = y$ and $x \not = y$ + \pfln $x = y$ + \begin{subpf} + \pfln $xRx$ is not valid as it contradicts irreflexive, $\forall x \in A(x\not R x)$ + \pfln Therefore, $xRx \implies x\not R x$ + \end{subpf} + \pfln $x \not = y$ + \begin{subpf} + \pfln $xRy \land yRx \implies x = y$ + \end{subpf} + \end{subpf} + \end{numpf} +\end{proof} + + +\pagebreak + +\section{Tables} + +\begin{tabular} {|l|c|c|} + Commutative & $p \land q \equiv q \land p$ & $p \lor q \equiv q \lor p$\\ + Associative & $p \land q \land r \equiv (p \land q) \land r$&\\ + Distributive & $p \land (q \lor r) \equiv (p \land q) \lor (p \land r)$&$p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)$\\ + Identity & $p \land \text{true} \equiv p$ & $p \lor \text{false} \equiv p$\\ + Negation & $p \lor \sim p \equiv \text{true}$ & $p \land \sim p \equiv \text{false}$\\ + Double Negative & $\sim(\sim p) \equiv p$ & \\ + Idempotent & $p \lor p \equiv p$ & $p \land p \equiv p$\\ + Universal bound & $p \lor \text{true} \equiv \text{true}$ & $p \land \text{false} \equiv \text{false}$\\ + de Morgan's & $\sim(p \land q) \equiv \sim p \lor \sim q$ & $\sim(p \lor q) \equiv \sim p \land \sim q$\\ + Absorption & $p \lor (p \land q) \equiv p$ & $p \land (p \lor q) \equiv p$\\ + Implication & $p \Rightarrow q \equiv \sim p \lor q$ & $$\\ + $\sim$(Implication) & $\sim (p \Rightarrow q) \equiv p \land \sim q$ & \\ + \hline & & \\ + Modus Ponens &$p \implies q, p$& $q$ \\ + Modus Tollens &$p \implies q, \sim q$& $\sim p$ \\ + Generalization &$p$& $p \lor q$ \\ + Specialization &$p \land q$& $p$ \\ + Conjunction &$p, q$& $p \land q$ \\ + Elimination &$p \lor q, \sim q$& $p$ \\ + Transitivity &$p \implies q, q \implies r$& $p \implies r$ \\ + Division into cases &$p \land q, p \implies r, q \implies r$& $r$ \\ + Contradiction &$\sim p \implies \text{false}$& $p$ \\ + \hline & & \\ + Commutative & $A \cup B = B \cup A$ & \\ + Associative & $(A \cup B) \cup C = A \cup (B \cup C)$ & \\ + Distributive & $A \cup (B \cap C) = (A \cup B) \cap (A \cup C)$ & $A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$\\ + Identity & $A \cup \emptyset = A$ & $A \cap U = A$\\ + Complement & $A \cup \bar A = U$ & $A \cap \bar A = \emptyset$\\ + Double Complement & $\bar{\bar A} = A$ & \\ + Idempotent & $A \cup A = A$ & $A \cap A = A$\\ + Universal Bound & $A \cup U = U$ & $A \cap \emptyset = \emptyset$ \\ + De Morgan's & $\overline{A \cup B} = \bar{A} \cap \bar{B}$ & $\overline{A \cap B} = \bar{A} \cup \bar{B}$\\ + Absorption & $A \cup (A \cap B) = A$ & $A \cap (A \cup B) = A$\\ + Complements of U and $\emptyset$ & $\bar U =\emptyset$ & $\bar \emptyset = U$\\ + Set Difference & $A \setminus B = A \cap \bar B$ &\\ + \hline & & \\ + F1 Commutative & $a + b = b + a$ & $ab = ba$ \\ + F2 Associative & $(a + b)+c = a + (b + c)$ & $(ab)c = a(bc)$ \\ + F3 Distributive & $a(b+c) = ab + ac$ & $(b+c)a = ba + ca$ \\ + F4 Identity & $0 +a = a + 0 = a$ & $1 \cdot a = a \cdot 1 = a $ \\ + F5 Additive inverses & $a + (-a) = (-a) + a = 0$ & \\ + F6 Reciprocals & $a \cdot \frac{1}{a} = \frac{1}{a} \cdot a = 1$ & $a \not = 0$ \\ + \hline & & \\ + T1 Cancellation Add & $a + b = a + c$ & $b = c$ \\ + T2 Possibility of Sub & There is one $x, a + x = b$ & $x = b - a$ \\ + T3 & $b - a = b + (-a)$ & \\ + T4 & $-(-a) = a$ & \\ + T5 & $a(b-c)=ab-ac$ & \\ + T6 & $0 \cdot a = a \cdot 0 = 0$ & \\ + T7 Cancellation Mul & $ab = ac$ & $b = c, a \not = 0$ \\ + T8 Possibility of Div & $a \not = 0, ax = b$ & $x = \frac{b}{a}$ \\ + T9 & $a \not = 0, \frac{b}{a} = b \cdot a^{-1}$ & \\ + T10 & $a \not = 0, (a^{-1})^{-1} = a$ & \\ + T11 Zero Product& $ab = 0 \Rightarrow a = 0 \lor b = 0$ & \\ + T12 Mul with -ve & $(-a)b = a(-b) - -(ab)$ & $-\frac{a}{b} = \frac{-a}{b} = \frac{a}{-b}$\\ + T13 Equiv Frac & $\frac{a}{b} = \frac{ac}{bc}$ & $b \not = 0, c \not = 0$\\ + T14 Add Frac & $\frac{a}{b} + \frac{c}{d} = \frac{ad + bc}{bd}$ & $b \not = 0, d \not = 0$\\ + T15 Mul Frac & $\frac{a}{b} \cdot \frac{c}{d} = \frac{ac}{bd}$ & $b \not = 0, d \not = 0$\\ + T16 Div Frac & $\frac{\frac{a}{b}}{\frac{c}{d}} = \frac{ac}{bd}$ & $b \not = 0, d \not = 0$\\ +\end{tabular} + +\begin{tabular} {|l|c|c|} + \hline & & \\ + Ord1 & $\forall a,b \in \mathbb{R}^+$ & $a + b > 0, ab > 0$\\ + Ord2 & $\forall a,b \in \mathbb{R}_{\not = 0}$ & $a$ is positive or negative and not both\\ + Ord3 & 0 is not positive & \\ + $a < b$ & means $b + (-a)$ is positive & \\ + $a \leq b$ & means $a < b$ or $a = b$ & \\ + $a < 0$ & means a is negative& \\ + T17 Trichotomy Law & $a < b \lor b > a \lor a = b$ & \\ + T18 Transitive Law & $a < b$ and $b < c$ & $a < c$\\ + T19 & $a < b$ & $a + c < b + c$ \\ + T20 & $a < b$ and $c > 0$ & $ac < bc$ \\ + T21 & $a \not = 0$ & $a^2 > 0$ \\ + T22 & $1 > 0$ & \\ + T23 & $a < b$ and $c < 0$ & $ac > bc$ \\ + T24 & $a < b$ & $-a > -b$ \\ + T25 & $ab > 0$ & a and b are both positive or negative \\ + T26 & $a < c$ and $b < d$ & $a+b < c+d$ \\ + T30 & $0 < a < c$ and $<0 < b < d$ & $0 < ab < cd$ \\ +\end{tabular} + +\end{document} diff --git a/cheatsheets/ma1301/cheetsheet.pdf b/cheatsheets/ma1301/cheetsheet.pdf new file mode 100644 index 0000000..efe207b Binary files /dev/null and b/cheatsheets/ma1301/cheetsheet.pdf differ diff --git a/cheatsheets/ma1301/cheetsheet.tex b/cheatsheets/ma1301/cheetsheet.tex new file mode 100644 index 0000000..fb4aa70 --- /dev/null +++ b/cheatsheets/ma1301/cheetsheet.tex @@ -0,0 +1,280 @@ +\documentclass[a4paper,twoside,notitlepage,10pt]{article} + +\usepackage[T1]{fontenc} +\usepackage{lipsum} +\usepackage{multicol} + +\usepackage[margin=0.5in]{geometry} + +\usepackage{lscape} +\usepackage{pdflscape} +\usepackage{mathtools} +\usepackage{parskip} +\usepackage{blindtext} +\usepackage{fontspec} +\usepackage{pgfplots} +\usepackage{array} +\usepackage{amsmath} +\newcolumntype{L}{>{$}l<{$}} % mathmode version of l +\pgfplotsset{compat = newest} + +\setmainfont{texgyrepagella}[ + Extension = .otf, + UprightFont = *-regular, + BoldFont = *-bold, + ItalicFont = *-italic, + BoldItalicFont = *-bolditalic, +] + +\begin{document} + +\title{MA1301 Midterm Reference} +\author{Yadunand Prem} +\setlength{\parindent}{0pt} + +\begin{landscape} +\begin{multicols}{3} + +\section{AP \& GP} + +\subsection{Series} + +Let $u_1, u_2,... u_n$ be a sequence + +then $S_n = u_1 + u_2 + u_3 + ... + u_n$ + +Result $u_1 = S_1$, $u_n = S_n - S_{n-1}$ + +In summation form: $S_n = \sum_{i=1}^{n} u_i$ + +\subsection{Arithmetic Series} + +Arithmetic Progression: $a, a+d, a+2d,...$ + +Common Difference: $d = u_{n} - u_{n-1}$ + +Nth Term: $u_n=a+(n-1)d$ + +Sum of Sequence: $\frac{n}{2}(u_1 + u_n) = \frac{n}{2}[2a+(n-1)d]$ + +\subsection{Geometric Series} + +Geometric Progression: $a, ar, ar^2, ar^3,...$ + +Common Ratio: $r = \frac{u_2}{u_1} = \frac{u_3}{u_2} = ... = \frac{u_n}{u_n-1}$ + +Nth Term: $u_n = ar^{n-1}$ + +Sum: $S_n = \frac{a}{1-r}(1-r^n),\, r \neq 1$ when $r = 1, S_n = na$ + +Sum to infinite: $\text{for}-1 < r < 1, \, S_{\infty} = \frac{a}{1-r}$ + +\subsection{Binomial Theorem} + +Coeff: $\binom{n}{r} = \frac{n!}{r!(n-r)!}$ + +Theorem: $(a+b)^n = \binom{n}{0}a^{n}b^{0} + \binom{n}{1}a^{n-1}b^{1} + ...+ \binom{n}{n}a^{0}b^{n}$ + +Generalized Coeff: $\binom{n}{r} = \frac{n(n-1)(n-2)...(n-r+1)}{r!}$ + +E.g. $\binom{\frac{1}{2}}{3} = \frac{(\frac{1}{2})(-\frac{1}{2})(-\frac{3}{2}))}{3!}$ + +Generalized Theorem: $(1+a)^n = 1+na+\frac{n(n-1)}{2!}a^2 + ...\,\\ +\text{when}\, n < 0 \text\,{and} -1 < a < 1$ + +Telescoping Series: $\sum^n_{r=m}(a_r - a_{r\pm1})$ + + +\section{Differentiation} +\renewcommand{\arraystretch}{1.2} + +\begin{tabular}{l| l} + Function & Differential\\ + $(f(x))^n$ & $nf'(x)(f(x))^{n-1}$\\ + $\cos(x)$ & $-\sin(x)$\\ + $\sin(x)$ & $\cos(x)$\\ + $\tan(x)$ & $\sec^2(x)$\\ + $\sec(x)$ & $\sec(x)\tan(x)$\\ + $\csc(x)$ & $-\csc(x)\cot(x)$\\ + $\cot(x)$ & $-\csc^2(x)$\\ + $e^{f(x)}$ & $f'(x)e^{f(x)}$\\ + $\ln(f(x))$ & $\frac{f'(x)}{f(x)}$\\ + $\sin^{-1}(f(x))$ & $\frac{f'(x)}{\sqrt{1-f(x)^2}}$\\ + $\cos^{-1}(f(x))$ & $-\frac{f'(x)}{\sqrt{1-f(x)^2}}$\\ + $\tan^{-1}(f(x))$ & $\frac{f'(x)}{1+f(x)^2}$\\ +\end{tabular} + +Product Rule: $\frac{d}{dx}(ab) = \frac{da}{dx}(b) + \frac{db}{dx}(a)$\\ +Quotient Rule: $\frac{d}{dx}(\frac{a}{b}) = \frac{\frac{da}{dx}(b) - \frac{db}{dx}(a)}{b^2}$\\ +Chain Rule: $\frac{dy}{dx} = \frac{dy}{du} \times \frac{du}{dx}$ + +Implicit: $\frac{d}{dx}(y^n) = ny^{n-1}\frac{dy}{dx}$\\ +$y=f(x)^{g(x)}\\ +\ln(y) = g(x)\ln(f(x))$ + +$\frac{d}{dx}(a^x) = a^{x}ln(a) \times \frac{d}{dx}(x)$ + +$\frac{d^2y}{dx^2} = \frac{d}{du}(\frac{dy}{dx}) \times \frac{du}{dx}$ + +Equation of tangent: $y-y_0 = m(x-x_0)$\\ +Equation of normal: $y-y_0 = -\frac{1}{m}(x-x_0)$ + + +\begin{tikzpicture} + \draw[->] (-2, 0) -- (2, 0) node[right] {$x$}; + \draw[->] (0, 0) -- (0, 3) node[above] {$y$}; + \draw[scale=0.5, domain=-2:2,smooth,variable=\x] plot({\x}, {\x*\x+1}) node[right] {$y=x^2+1$}; + \draw[scale=0.5, domain=-2.5:2.5,smooth,variable=\x] plot({\x}, {1}) node[right] {$y=1$}; +\end{tikzpicture} + +Tangent $//$ $x$-axis, $\frac{dy}{dx} = 0$ + +\begin{tikzpicture} + \draw[->] (0, 0) -- (2, 0) node[right] {$x$}; + \draw[->] (0, -2) -- (0, 2) node[above] {$y$}; + \draw[scale=0.5, domain=-2:2,smooth,variable=\y] plot({\y*\y+1}, {\y}) node[right] {$x=y^2+1$}; + \draw[scale=0.5, domain=-2.5:2.5,smooth,variable=\y] plot({1}, {\y}) node[right] {$x=1$}; +\end{tikzpicture} + +Tangent $//$ $y$-axis, $\frac{dy}{dx} = \pm\infty$ + +If $f \approx a, f(x) \approx f'(a)[x-a] + f(a)$\\ +If $f'(x) > 0$ it is increasing, else decreasing\\ +If $f''(x) > 0$ it is concave up, else concave down\\\\ +If $f'(x) = 0 \ \& f''(x) < 0$ it is local maximum\\ +If $f'(x) = 0 \ \& f''(x) > 0$ it is local minimum\\ +If $f'(x) = 0 \ \& f''(x) = 0$ test fails\\ + + +\subsection{Trigonometric Identities} + +\begin{tabular}{|L|} + \sin^2{\theta} + \cos^2{\theta} = 1 \\ + \tan^2{\theta} + 1 = \sec^2{\theta} \\ + 1 + \cot^2{\theta} = \csc^2{\theta} \\ + \hline + \sin{2\theta} = 2\sin{\theta}\cos{\theta} \\ + \cos{2\theta} = \cos^2{\theta}-\sin^2{\theta} \\ + \cos{2\theta} = 2\cos^2{\theta}-1 \\ + \cos{2\theta} = 1-2\sin^2{\theta} \\ + \tan{2\theta} = \frac{2\tan{\theta}}{1-\tan^2{\theta}} \\ + \hline + \sin({\alpha + \beta}) = \sin{\alpha}\cos{\beta} \pm \cos{\alpha}\sin{\beta} \\ + \cos({\alpha + \beta}) = \cos{\alpha}\cos{\beta} \mp \sin{\alpha}\sin{\beta} +\end{tabular} + + +\end{multicols} +\begin{multicols}{2} + +\section{Integration} + +\subsection{Standard Integrals} +\begin{tabular}{|L|L|L} +1 & \int(ax+b)^n\ dx & \frac{(ax+b)^{n+1}}{(n+1)a} + C \\ +2 & \int \frac{1}{ax+b}\ dx & \frac{1}{a}\ln|ax+b| + C \\ +3 & \int e^{ax+b}\ dx & \frac{1}{a}e^{ax+b} + C \\ +4 & \int \sin(ax+b)\ dx & -\frac{1}{a}\cos(ax+b) + C \\ +5 & \int \cos(ax+b)\ dx & \frac{1}{a}\sin(ax+b) + C \\ +6 & \int \tan(ax+b)\ dx & \frac{1}{a}\ln|\sec(ax+b)| + C \\ +7 & \int \sec(ax+b)\ dx & \frac{1}{a}\ln|\sec(ax+b) + \tan(ax+b)| + C \\ +8 & \int \csc(ax+b)\ dx & -\frac{1}{a}\ln|\csc(ax+b) + \cot(ax+b)| + C \\ +9 & \int \cot(ax+b)\ dx & -\frac{1}{a}\ln|\csc(ax+b)| + C \\ +10 & \int \sec^2(ax+b)\ dx & \frac{1}{a}\tan(ax+b) + C \\ +11 & \int \csc^2(ax+b)\ dx & -\frac{1}{a}\cot(ax+b) + C \\ +12 & \int \sec(ax+b) \cdot \tan(ax+b)\ dx & \frac{1}{a}\sec(ax+b) + C \\ +13 & \int \csc(ax+b) \cdot \cot(ax+b)\ dx & -\frac{1}{a}\csc(ax+b) + C \\ +14 & \int \frac{1}{a^2+(x+b)^2}\ dx & \frac{1}{a}\tan^{-1}(\frac{x+b}{a})+ C \\ +15 & \int \frac{1}{\sqrt{a^2-(x+b)^2}}\ dx & \sin^{-1}(\frac{x+b}{a})+ C \\ +16 & \int \frac{-1}{\sqrt{a^2-(x+b)^2}}\ dx & \cos^{-1}(\frac{x+b}{a})+ C \\ +17 & \int \frac{1}{a^2-(x+b)^2}\ dx & \frac{1}{2a}\ln|\frac{x+b+a}{x+b-a}|+ C \\ +18 & \int \frac{1}{(x+b)^2-a^2}\ dx & \frac{1}{2a}\ln|\frac{x+b-a}{x+b+a}|+ C \\ +19 & \int \frac{1}{\sqrt{(x+b)^2+a^2}}\ dx & \ln|(x+b) + \sqrt{(x+b)^2+a^2}| + C \\ +20 & \int \frac{1}{\sqrt{(x+b)^2-a^2}}\ dx & \ln|(x+b) + \sqrt{(x+b)^2-a^2}| + C \\ +21 & \int \frac{1}{\sqrt{(x+b)^2-a^2}}\ dx & \ln|(x+b) + \sqrt{(x+b)^2-a^2}| + C \\ +21 & \int a^x\ dx & \frac{a^x}{\ln a} + C \\ + +\end{tabular} + +\subsection{Integration by Parts} +$\int u\ dv = uv - \int v\ du$ + +Rule for choosing $u$ + +\begin{tabular}{|l|L|} + Logarithm & \ln(ax+b) \\ + Inverse Trigo & \sin^{-1}(ax+b) \\ + Algebraic & x, x^{10} \\ + Trigo & \sin (ax+b) \\ + Expo & e^x, 19^x \\ +\end{tabular} + +\subsection{Area between 2 curves} + +$A = \int^b_a g(x) - f(x)dx,\ \text{when}\ g(x)\ \text{is above}\ f(x)$ + +\subsection{Volume of Revolution} + +$V = \pi\int^b_a(f(x)-a)^2\ dx$ when $a$ is a line parallel to $x$ or axis + +$V = \pi\int^b_a(f(x))^2\ dx - \pi\int^b_a(g(x))^2\ dx$ when $f(x)$ is higher than $g(x)$ + +\section{Vectors} + +$\overrightarrow{OA} = a = \big(\begin{smallmatrix} + x_1 \\ + y_1 \\ + z_1 \\ +\end{smallmatrix}\big)= x_1\text{i} + y_1\text{j}+ z_1\text{k}$ + +$\overrightarrow{OB} = b = \big(\begin{smallmatrix} + x_2 \\ + y_2 \\ + z_2 \\ +\end{smallmatrix}\big) = x_2\text{i} + y_2\text{j}+ z_2\text{k}$ + +Magnitude = $|\overrightarrow{AB}| = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}$ + +$\overrightarrow{AB} =\overrightarrow{OB} - \overrightarrow{OA}$ = $\big(\begin{smallmatrix} + x_2 - x_1 \\ + y_2 - y_1 \\ +\end{smallmatrix}\big)$ + +Unit Vector : $\hat{v} = \frac{1}{|v|}v$ + +Dot Product: $a \cdot b = x_1x_2+y_1y_2+z_1z_2 = |a||b|\cos\theta $ + +If $a\perp b$, $a \cdot b = 0$ + +$\theta = \cos^{-1}\big(\frac{a \cdot b}{|a||b|}\big)$ + +Cross Product: $a \times b = \begin{pmatrix} + y_1z_2 - y_2z_1 \\ + -(x_1z_2 - x_2z_2)\\ + x_1y_2 - x_2y_1) +\end{pmatrix}$ + +Area of $\triangle ABC = \frac{1}{2}|\overrightarrow{CA} \times \overrightarrow{CB}|$ + +$|a \times b| = |a||b|\sin\theta$ + +Line: $r = a + \lambda u \Leftrightarrow r = (x_1\text{i} + y_1\text{j} + z_1\text{k}) + t(a\text{i} + b\text{j} + c\text{k})$ where $a$ is a point and $u$ is a direction vector + +If Point $P\perp$ to line $r = a + s \overrightarrow{u}$, $Q = (a + \lambda \overrightarrow{u})$, $\overrightarrow{PQ} \cdot \overrightarrow{u} = 0$ + +Shortest distance = $|PQ|$ + +Plane: $(\overrightarrow{r} - \overrightarrow{a}) \cdot n = 0 \Leftrightarrow \overrightarrow{r} \cdot \overrightarrow{n} = \overrightarrow{a} \cdot \overrightarrow{n}$, where $a$ and $r$ are 2 vectors on the plane and $n$ is normal to the plane + +Cartesian Eqn of plane: $r \cdot n = d \Leftrightarrow ax + by + cz = d$, where $n = ai + bj + ck$ and $r = xi + yj + zk$ + +Angle between planes: $\cos\theta =|\frac{n_1 \cdot n_2}{|n_1||n_2|}|$ +Angle between line and plane: $\sin\theta = |\frac{u \cdot n}{|u||n|}|$ + +Intersection of 2 planes: $r = a + \lambda(n_1 \times n_2)$ + +\end{multicols} + +\end{landscape} + +\end{document} diff --git a/cheatsheets/ma1521/finals.pdf b/cheatsheets/ma1521/finals.pdf new file mode 100644 index 0000000..cc78556 Binary files /dev/null and b/cheatsheets/ma1521/finals.pdf differ diff --git a/cheatsheets/ma1521/finals.tex b/cheatsheets/ma1521/finals.tex new file mode 100644 index 0000000..f1926e4 --- /dev/null +++ b/cheatsheets/ma1521/finals.tex @@ -0,0 +1,362 @@ +\documentclass[10pt,landscape]{article} +\usepackage[scaled=0.8]{helvet} + +\usepackage{calc} +\usepackage{multicol} +\usepackage{ifthen} +\usepackage[a4paper,margin=3mm,landscape]{geometry} +\usepackage{amsmath,amsthm,amsfonts,amssymb} +\usepackage{hyperref} +\usepackage{newtxtext} +\usepackage{enumitem} +\usepackage{amssymb} +\usepackage[table]{xcolor} +\usepackage{vwcol} +\usepackage{tikz} +\usepackage{wrapfig} +\usepackage{makecell} +% Testing % +\usepackage{blindtext} +\usetikzlibrary{calc} + +\setlist{nosep} +\graphicspath{ {./images/} } + +\pagestyle{empty} +\newenvironment{tightcenter}{% + \setlength\topsep{0pt} + \setlength\parskip{0pt} + \begin{center} +}{% + \end{center} +} + +% redefine section commands to use less space +\makeatletter +\renewcommand{\section}{\@startsection{section}{1}{0mm}% + {-1ex plus -.5ex minus -.2ex}% + {0.5ex plus .2ex}%x + {\normalfont\large\bfseries}} +\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}% + {-1explus -.5ex minus -.2ex}% + {0.5ex plus .2ex}% + {\normalfont\normalsize\bfseries}} +\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}% + {-1ex plus -.5ex minus -.2ex}% + {1ex plus .2ex}% + {\normalfont\small\bfseries}}% +\renewcommand{\familydefault}{\sfdefault} +\renewcommand\rmdefault{\sfdefault} +% makes nested numbering (e.g. 1.1.1, 1.1.2, etc) +\renewcommand{\labelenumii}{\theenumii} +\renewcommand{\theenumii}{\theenumi.\arabic{enumii}.} +\renewcommand\labelitemii{•} +% for logical not operator +\renewcommand{\lnot}{\mathord{\sim}} +\renewcommand{\bf}[1]{\textbf{#1}} +\newcommand{\abs}[1]{\vert #1 \vert} +\newcommand{\Mod}[1]{\ \mathrm{mod}\ #1} +\newcommand{\vv}[1]{\boldsymbol{#1}} +\newcommand{\VV}[1]{\overrightarrow{#1}} +\newcommand{\cvv}[1]{\left(\begin{smallmatrix}#1\end{smallmatrix}\right)} + +\makeatother +\definecolor{myblue}{cmyk}{1,.72,0,.38} +% Define BibTeX command +\everymath\expandafter{\the\everymath \color{myblue}} +\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em + T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}} +\let\iff\leftrightarrow +\let\Iff\Leftrightarrow +\let\then\rightarrow +\let\Then\Rightarrow + +% Don't print section numbers +\setcounter{secnumdepth}{0} + +\setlength{\parindent}{0pt} +\setlength{\parskip}{0pt plus 0.5ex} +%% this changes all items (enumerate and itemize) +\setlength{\leftmargini}{0.5cm} +\setlength{\leftmarginii}{0.5cm} +\setlist[itemize,1]{leftmargin=2mm,labelindent=1mm,labelsep=1mm} +\setlist[itemize,2]{leftmargin=4mm,labelindent=1mm,labelsep=1mm} + +%My Environments +\newtheorem{example}[section]{Example} +% ----------------------------------------------------------------------- + +\begin{document} +\raggedright +\footnotesize +\begin{multicols*}{4} + \setlength{\columnseprule}{0.25pt} + \setlength{\premulticols}{1pt} + \setlength{\postmulticols}{1pt} + \setlength{\multicolsep}{1pt} + \setlength{\columnsep}{2pt} + +\section{Function and Limits} +\begin{itemize} + \item $\lim\limits_{x\to \pm \infty}\frac{Ax^\alpha}{Bx^\beta} + \begin{cases} + 0 & \text{if} \alpha < \beta\\ + \frac{A}{B} & \text{if} \alpha = \beta\\ + \pm \infty & \text{if} \alpha > \beta\\ + \end{cases}$ + \item $\lim\limits_{x\to c}\frac{sin(g(x))}{g(x)} = 1(\lim\limits_{x \to c}g(x) = 0)$ + \item $\lim\limits_{x\to c}\frac{tan(g(x))}{g(x)} = 1$ + \item $\lim\limits_{x\to 0}\frac{sin(x)}{x} = 1$ + \item $\lim\limits_{x\to 0}\frac{tan(x)}{x} = 1$ +\end{itemize} + + +\section{Differentiation} +parametric differentiaton: $\frac{d^2y}{dx^2} = \frac{d}{dx}(\frac{dy}{dx}) = \frac{\frac{d}{dt}(\frac{dy}{dx})}{\frac{dx}{dt}}$ + +\begin{tabular}{|>{\color{black}}c | >{\color{black}}c|} + \hline + $f(x)$ & $f'(x)$ + \\ \hline + \rule{0pt}{2.3ex} % top spacing + $\tan x$ & $\sec ^2 x$ \\ + $\csc x$ & $-\csc x \cot x$ \\ + $\sec x$ & $\sec x \tan x$ \\ + $\cot x$ & $- \csc ^2 x$ + \\ \hline + \rule{0pt}{2.3ex} % top spacing + $a^{f(x)}$ & $\ln a \cdot f'(x)a^{f(x)}$ \\ + $\log_af(x)$ & $\log_a e \cdot \frac{f'(x)}{f(x)}$ + \\[1ex] \hline + \rule{0pt}{3ex} % top spacing + $\sin^{-1} f(x)$ & $\frac{f'(x)}{\sqrt{1-[f(x)]^2}}, \ \ _{\vert f(x) \vert < 1}$ \\[1.5ex] + $\cos^{-1} f(x)$ & $-\frac{f'(x)}{\sqrt{1-[f(x)]^2}}, \ \ _{\vert f(x) \vert < 1}$ \\[1.5ex] + $\tan^{-1} f(x)$ & $\frac{f'(x)}{1 + [f(x)]^2}$ \\[1.5ex] + $\cot^{-1} f(x)$ & $-\frac{f'(x)}{1 + [f(x)]^2}$ \\[1.5ex] + $\sec^{-1} f(x)$ & $\frac{f'(x)}{\vert f(x) \vert \sqrt{[f(x)]^2-1}}$ \\[1.5ex] + $\csc^{-1} f(x)$ & $-\frac{f'(x)}{\vert f(x) \vert \sqrt{[f(x)]^2-1}}$ \\[2ex] + \hline +\end{tabular} + +\textbf{Second Derivative} Test: $f'(c) = 0, f''(c) < 0$ then local max, $f''(c) > 0$ local min. + +\textbf{L'Hopital's Rule}: Given $\lim\limits_{x\to c}f(x) $ and $ g(x) = 0 / \pm \infty$ $ \lim\limits_{x \to c}\frac{f(x)}{g(x)} = \lim\limits_{x \to c}\frac{f'(x)}{g'(x)}$ +\begin{itemize} + \item Use for $\frac{0}{0}$ or $\frac{\infty}{\infty}$ +\end{itemize} + +\subsection*{Trigo Identities} +\begin{enumerate} + \item $\sec^2x - 1 = \tan^2x$ + \item $\csc^2x - 1 = \cot^2x$ + \item $\sin A\cos A = \frac{1}{2}\sin2A$ + \item $\cos^2A = \frac{1}{2}(1+\cos2A)$ + \item $\sin^2A = \frac{1}{2}(1-\cos2A)$ + \item $\sin A\cos B = \frac{1}{2}(\sin(A + B) + \sin(A - B)$ + \item $\cos A\sin B = \frac{1}{2}(\sin(A + B) - \sin(A - B)$ + \item $\cos A\cos B = \frac{1}{2}(\cos(A + B) + \cos(A - B)$ + \item $\sin A\sin B = \frac{1}{2}(\cos(A + B) - \cos(A - B)$ +\end{enumerate} + +\section{Integration} + +\begin{tabular}{|>{\color{black}}c | >{\color{black}}c|} + \hline + $f(x)$ & $\int f(x)$\\ + $\tan ax$ & $\frac{1}{a}\ln|\sec(ax)|$\\ + $\cot ax$ & $\frac{1}{a}\ln|\cot(ax)|$\\ + $\sec ax$ & $\frac{1}{a}\ln|\sec(ax) + tan(ax)|$\\ + $\csc ax$ & $\frac{1}{a}\ln|\csc(ax) + cot(ax)|$\\ + \hline + $\frac{1}{a^2+(x+b)^2}$ & $\frac{1}{a}\tan^{-1}(\frac{x+b}{a})$\\ + $\frac{1}{\sqrt{a^2-(x+b)^2}}$ & $\sin^{-1}(\frac{x+b}{a})$\\ + $\frac{1}{a^2-(x+b)^2}$ & $\frac{1}{2a}\ln|\frac{x+b+a}{x+b-a}|$\\ + $\frac{1}{(x+b)^2-a^2}$ & $\frac{1}{2a}\ln|\frac{x+b-a}{x+b+a}|$\\ + \hline +\end{tabular} + +\textbf{Substitution} $\int f(g(x)) \cdot g'(x) dx = \int f(u) du, u = g(x)$ + +\textbf{By Parts} $\int u v' dx = uv - \int u'v dx$, order: LIATE: Differentiate to integrate + +\subsection{Application of Integration} +about x axis +\begin{itemize} + \item Vol Disk: $V = \pi \int^b_a f(x)^2 - g(x)^2 dx$ + \item Vol Shell: $V = 2\pi\int^b_a x|f(x)-g(x)|dx$ (absolute!!) + \item Length of curve: $\int^b_a \sqrt{1+f'(x)^2}dx$ +\end{itemize} +\section{Series} +TODO!! + +\section{Vectors} +unit vector: $\hat{p} = \frac{p}{|p|}$, $\VV{AB} = \VV{OB} - \VV{OA}$ +\begin{center} + \begin{multicols}{2} + \begin{tikzpicture}[scale=0.8, every node/.style={transform shape}] + \coordinate[label=below left:O] (O) at (0,0); + \coordinate[label=A] (A) at (0.3,1.6); + \coordinate[label=B] (B) at (1.5, 1.4); + \coordinate[label=P] (P) at (1, 1.5); + \draw (O) + -- node[left] {$\vv{a}$} (A) + -- node[above] {$\lambda$} (P) + -- node[above] {$\mu$} (B) + -- node[right] {$\vv{b}$} (O) + -- node[left] {$\vv{p}$} (P); + \end{tikzpicture} + \\ \textbf{ratio theorem} + \\* $\vv{p} = \frac{\mu\vv{a} + \lambda\vv{b}}{\lambda + \mu}$ + \newline + \\ \textbf{midpoint theorem} + \\* $\vv{p} = \frac{\vv{a} + \vv{b}}{2}$ + \end{multicols} +\end{center} +\subsection{Dot Product} +\begin{itemize} + \item $\VV{a} \cdot \VV{b} = a_1b_1 + a_2b_2 + a_3b_3 = |a||b|\cos\theta$ + \item $a \perp b \Then a \cdot b = 0$ + \item $a \parallel b \Then a \cdot b = |a||b|$ +\end{itemize} + +\subsection{Cross Product} +$\vv{a} \times \vv{b} = \begin{vmatrix} +\vv{i} & \vv{j} & \vv{k} \\ +a_i & a_2 & a_3 \\ +b_i & b_2 & b_3 +\end{vmatrix} = \begin{pmatrix} (a_2b_3 - a_3b_2) \\ -(a_1b_3 - a_3b_1) \\ (a_1b_2 - a_2b_1) \end{pmatrix}$ + +\begin{center} +\begin{multicols}{2} + $|\vv{a} \times \vv{b}| = |\vv{a}||\vv{b}|\sin\theta$ + $a \perp b \Then a \times b = |a||b|$ + $a \parallel b \Then a \times b = 0$ + Parallelogram = $|\vv{a} \times \vv{b}|$ +\end{multicols} +\end{center} + +\subsection{Projection} +\begin{multicols}{2} +\begin{tikzpicture}[scale=0.7, every node/.style={transform shape}] + \coordinate[label=below left:O] (O) at (0,0); + \coordinate[label=right:A] (A) at (2, 1); + \coordinate[label=below:B] (B) at (3, 0); + \coordinate[label=below:N] (N) at (2, 0); + \draw (A) + -- node[above] {$\vv{a}$} (O) + -- node[below] {$\vv{b}$} (B); + \draw[shorten >=0pt, dashed] (A) -- (N); +\end{tikzpicture} +$\triangle ANO = \frac{1}{2} \abs{\VV{OA} \times \VV{ON}}$ +\columnbreak + +$\text{comp}_{\vv{b}}\vv{a} = |\vv{b}|\cos\theta = \frac{\vv{a}\cdot \vv{b}}{|\vv{a}|}$ +$\text{proj}_{\vv{b}}\vv{a} = \text{comp}_{\vv{b}}\vv{a} \cdot \frac{a}{|a|} = \VV{ON} = \frac{\vv{a}\cdot \vv{b}}{\vv{a}\cdot \vv{a}}\vv{a} = \frac{\vv{a} \cdot \vv{b}}{|\vv{a}|^2}\vv{b}$ +\end{multicols} + +\subsection{Lines} +\begin{multicols}{2} +$\vv{r} = \vv{r}_0 + t\vv{v} = \langle x,y,z\rangle$ +$\langle x_0,y_0,z_0\rangle + t\langle a,b,c\rangle$ +$\begin{pmatrix} + x_0 + at \\ + y_0 + bt \\ + z_0 + ct \\ +\end{pmatrix}$ +\end{multicols} +\subsection{Planes} +$\vv{n} = \langle a, b, c \rangle, \vv{r} = \langle x, y, z \rangle,\vv{r}_0\langle x_0, y_0, c_0 \rangle$\\ +Scalar: $\vv{n} \cdot \vv{r} = \vv{n} \cdot \vv{r}_0$\\ +Cartesian: $ax + by + cz = d$ +\subsection{Distance from Point to Plane} +$\frac{|ax_0 + by_0 + cz_0 - d|}{\sqrt{a^2 + b^2 + c^2}}$ + +\section{Partial Derivatives} +\subsection{Chain Rule} +For $z(t) = f(x(t), y(t))$, +\\* $\frac{dz}{dt} = \frac{\partial z}{\partial x}\frac{dx}{dt} + \frac{\partial z}{\partial y}\frac{dy}{dt}$ + +For $z(s, t) = f(x(s,t), y(s,t))$, +\\* $\frac{\partial z}{\partial t} = \frac{\partial z}{\partial x}\frac{\partial x}{\partial t} + \frac{\partial z}{\partial y}\frac{\partial y}{\partial t}$ +\\* $\frac{\partial z}{\partial s} = \frac{\partial z}{\partial x}\frac{\partial x}{\partial s} + \frac{\partial z}{\partial y}\frac{\partial y}{\partial s}$ + +Arc Length of $r(t)$: $\int^b_a |\vv{r}'(t)|dt$ + +\subsection{Implicit Differentiation} +$\frac{\partial z}{\partial x} =- \frac{F_x}{F_z}$ +$\frac{\partial z}{\partial y} =- \frac{F_y}{F_z}$ + +\subsection{Directional Derivative} +Gradient vector at $f(x,y): \triangle f = f_x\vv{i} + f_y\vv{j}$ + +$D_uf(x, y) = \langle f_x, f_y \rangle \cdot \langle a, b \rangle = \langle f_x, f_y\rangle \cdot \hat{\vv{u}} = \triangle f \cdot \hat{\vv{u}}$ (Unit Vector) + +Tangent Plane: $\triangle f \cdot \langle x-x_0, y-y_0,z-z_0\rangle = 0$ + +\subsection{Critical Points} +$D = f_{xx}(a,b)f_{yy}(a,b) - (f_{x,y}(a,b))^2$ +\def\arraystretch{1.2} +\begin{tabular}{| c | c | c |} + \hline $D$ & $f_{xx}(a,b)$ & \textbf{local} + \\\hline + & + & \text{min} + \\\hline + & - & \text{max} + \\\hline - & \text{any} & \text{saddle point} + \\\hline 0 & \text{any} & \text{no conclusion} + \\\hline +\end{tabular} +\section{Double Integrals} +\subsection{Type I} +\begin{multicols}{2} +\includegraphics[width=\linewidth]{Type I} +\columnbreak + +$\int^b_a\int^{g_2(x)}_{g_1(x)}f(x,y)dydx$ +\newline +\newline +$D = \{(x,y): a \leq x \leq b,$ $g_1(x) \leq y \leq g_2(x)\}$ +\end{multicols} +\subsection{Type II} +\begin{multicols}{2} +\includegraphics[width=\linewidth]{Type II} +\columnbreak + +$\int^d_c\int^{h_2(y)}_{h_1(y)}f(x,y)dxdy$ +\newline +\newline +$D = \{(x,y): c \leq y \leq d,$ $ h_1(y) \leq x \leq h_2(y)\}$ +\end{multicols} + +\subsection{Polar Coordinates} +\begin{multicols}{2} +\includegraphics[width=\linewidth]{polar} +\columnbreak + +$x = r\cos\theta$\\ +$y = r\sin\theta$\\ +$R = \{(r, \theta): 0 \leq a \leq r \leq b,$ $\alpha \leq \theta \leq \beta\}$ +\newline +\newline +$\int^\beta_\alpha\int^b_af(r\cos\theta, r\sin\theta)rdrd\theta$ +\end{multicols} + +\subsection{Surface Area} +$S = \iint_R\sqrt{f_x^2 + f_y^2 + 1} dA$ + +\section{ODE} +\begin{tabular}{|>{\color{black}}c | >{\color{black}}c|} + \hline + form & change of variable \\ + \hline + $\frac{dy}{dx} = f(x)g(y)$ & $\int \frac{1}{g(y)}dy = \int f(x)dx + C$\\ + \hline + $y'=g(\frac{y}{x})$ & \makecell{Set $v = \frac{y}{x}$ \\ $\Then y' = v + xv' $}\\ + \hline + \makecell{ $y'=f(ax + by + c)$\\ $\Then y' = \frac{ax+by+c}{\alpha x + \beta y + \gamma}$} & Set $v = ax+by$ \\ + \hline + $y' + P(x)y = Q(x)$ & \makecell{$R = e^{\int P(x)dx}$ \\ $\Then y \cdot R = \int Q \cdot R dx $}\\ + $y' + P(x)y = Q(x)y^n$ & \makecell{$z = y^{1-n}$ \\ $\Then$ sub in Z \\ solve linear}\\ +\end{tabular} + + +\end{multicols*} +\end{document} diff --git a/cheatsheets/ma1521/images/Type I.png b/cheatsheets/ma1521/images/Type I.png new file mode 100644 index 0000000..1f6e400 Binary files /dev/null and b/cheatsheets/ma1521/images/Type I.png differ diff --git a/cheatsheets/ma1521/images/Type II.png b/cheatsheets/ma1521/images/Type II.png new file mode 100644 index 0000000..e39f9d6 Binary files /dev/null and b/cheatsheets/ma1521/images/Type II.png differ diff --git a/cheatsheets/ma1521/images/polar.png b/cheatsheets/ma1521/images/polar.png new file mode 100644 index 0000000..46fd411 Binary files /dev/null and b/cheatsheets/ma1521/images/polar.png differ diff --git a/cs2030s/Lab9/Lab9a/MatrixMultiplication.java b/cs2030s/Lab9/Lab9a/MatrixMultiplication.java deleted file mode 100644 index 69d41f0..0000000 --- a/cs2030s/Lab9/Lab9a/MatrixMultiplication.java +++ /dev/null @@ -1,60 +0,0 @@ -import java.util.concurrent.RecursiveTask; - -class MatrixMultiplication extends RecursiveTask { - - /** The fork threshold. */ - private static final int FORK_THRESHOLD = 1024; // Find a good threshold - - /** The first matrix to multiply with. */ - private final Matrix m1; - - /** The second matrix to multiply with. */ - private final Matrix m2; - - /** The starting row of m1. */ - private final int m1Row; - - /** The starting col of m1. */ - private final int m1Col; - - /** The starting row of m2. */ - private final int m2Row; - - /** The starting col of m2. */ - private final int m2Col; - - /** - * The dimension of the input (sub)-matrices and the size of the output - * matrix. - */ - private int dimension; - - /** - * A constructor for the Matrix Multiplication class. - * @param m1 The matrix to multiply with. - * @param m2 The matrix to multiply with. - * @param m1Row The starting row of m1. - * @param m1Col The starting col of m1. - * @param m2Row The starting row of m2. - * @param m2Col The starting col of m2. - * @param dimension The dimension of the input (sub)-matrices and the size - * of the output matrix. - */ - MatrixMultiplication(Matrix m1, Matrix m2, int m1Row, int m1Col, int m2Row, - int m2Col, int dimension) { - this.m1 = m1; - this.m2 = m2; - this.m1Row = m1Row; - this.m1Col = m1Col; - this.m2Row = m2Row; - this.m2Col = m2Col; - this.dimension = dimension; - } - - - @Override - public Matrix compute() { - // Modify this - return Matrix.recursiveMultiply(m1, m2, m1Row, m1Col, m2Row, m2Col, dimension); - } -} diff --git a/cs2030s/Lab1/Array.java b/labs/cs2030s/Lab1/Array.java similarity index 100% rename from cs2030s/Lab1/Array.java rename to labs/cs2030s/Lab1/Array.java diff --git a/cs2030s/Lab1/ArrayTest.java b/labs/cs2030s/Lab1/ArrayTest.java similarity index 100% rename from cs2030s/Lab1/ArrayTest.java rename to labs/cs2030s/Lab1/ArrayTest.java diff --git a/cs2030s/Lab1/ArrivalEvent.java b/labs/cs2030s/Lab1/ArrivalEvent.java similarity index 100% rename from cs2030s/Lab1/ArrivalEvent.java rename to labs/cs2030s/Lab1/ArrivalEvent.java diff --git a/cs2030s/Lab1/CS2030STest.java b/labs/cs2030s/Lab1/CS2030STest.java similarity index 100% rename from cs2030s/Lab1/CS2030STest.java rename to labs/cs2030s/Lab1/CS2030STest.java diff --git a/cs2030s/Lab1/Customer.java b/labs/cs2030s/Lab1/Customer.java similarity index 100% rename from cs2030s/Lab1/Customer.java rename to labs/cs2030s/Lab1/Customer.java diff --git a/cs2030s/Lab1/DepartureEvent.java b/labs/cs2030s/Lab1/DepartureEvent.java similarity index 100% rename from cs2030s/Lab1/DepartureEvent.java rename to labs/cs2030s/Lab1/DepartureEvent.java diff --git a/cs2030s/Lab1/Event.java b/labs/cs2030s/Lab1/Event.java similarity index 100% rename from cs2030s/Lab1/Event.java rename to labs/cs2030s/Lab1/Event.java diff --git a/cs2030s/Lab1/JoinCounterQueueEvent.java b/labs/cs2030s/Lab1/JoinCounterQueueEvent.java similarity index 100% rename from cs2030s/Lab1/JoinCounterQueueEvent.java rename to labs/cs2030s/Lab1/JoinCounterQueueEvent.java diff --git a/cs2030s/Lab1/JoinShopQueueEvent.java b/labs/cs2030s/Lab1/JoinShopQueueEvent.java similarity index 100% rename from cs2030s/Lab1/JoinShopQueueEvent.java rename to labs/cs2030s/Lab1/JoinShopQueueEvent.java diff --git a/cs2030s/Lab1/Lab1.java b/labs/cs2030s/Lab1/Lab1.java similarity index 100% rename from cs2030s/Lab1/Lab1.java rename to labs/cs2030s/Lab1/Lab1.java diff --git a/cs2030s/Lab1/Lab2.java b/labs/cs2030s/Lab1/Lab2.java similarity index 100% rename from cs2030s/Lab1/Lab2.java rename to labs/cs2030s/Lab1/Lab2.java diff --git a/cs2030s/Lab1/Lab3.java b/labs/cs2030s/Lab1/Lab3.java similarity index 100% rename from cs2030s/Lab1/Lab3.java rename to labs/cs2030s/Lab1/Lab3.java diff --git a/cs2030s/Lab1/Makefile b/labs/cs2030s/Lab1/Makefile similarity index 100% rename from cs2030s/Lab1/Makefile rename to labs/cs2030s/Lab1/Makefile diff --git a/cs2030s/Lab1/Queue.java b/labs/cs2030s/Lab1/Queue.java similarity index 100% rename from cs2030s/Lab1/Queue.java rename to labs/cs2030s/Lab1/Queue.java diff --git a/cs2030s/Lab1/QueueTest.java b/labs/cs2030s/Lab1/QueueTest.java similarity index 100% rename from cs2030s/Lab1/QueueTest.java rename to labs/cs2030s/Lab1/QueueTest.java diff --git a/cs2030s/Lab1/ServiceBeginEvent.java b/labs/cs2030s/Lab1/ServiceBeginEvent.java similarity index 100% rename from cs2030s/Lab1/ServiceBeginEvent.java rename to labs/cs2030s/Lab1/ServiceBeginEvent.java diff --git a/cs2030s/Lab1/ServiceCounter.java b/labs/cs2030s/Lab1/ServiceCounter.java similarity index 100% rename from cs2030s/Lab1/ServiceCounter.java rename to labs/cs2030s/Lab1/ServiceCounter.java diff --git a/cs2030s/Lab1/ServiceEndEvent.java b/labs/cs2030s/Lab1/ServiceEndEvent.java similarity index 100% rename from cs2030s/Lab1/ServiceEndEvent.java rename to labs/cs2030s/Lab1/ServiceEndEvent.java diff --git a/cs2030s/Lab1/Shop.java b/labs/cs2030s/Lab1/Shop.java similarity index 100% rename from cs2030s/Lab1/Shop.java rename to labs/cs2030s/Lab1/Shop.java diff --git a/cs2030s/Lab1/ShopSimulation.java b/labs/cs2030s/Lab1/ShopSimulation.java similarity index 100% rename from cs2030s/Lab1/ShopSimulation.java rename to labs/cs2030s/Lab1/ShopSimulation.java diff --git a/cs2030s/Lab1/Simulation.java b/labs/cs2030s/Lab1/Simulation.java similarity index 100% rename from cs2030s/Lab1/Simulation.java rename to labs/cs2030s/Lab1/Simulation.java diff --git a/cs2030s/Lab1/Simulator.java b/labs/cs2030s/Lab1/Simulator.java similarity index 100% rename from cs2030s/Lab1/Simulator.java rename to labs/cs2030s/Lab1/Simulator.java diff --git a/cs2030s/Lab1/inputs/Lab1.1.in b/labs/cs2030s/Lab1/inputs/Lab1.1.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab1.1.in rename to labs/cs2030s/Lab1/inputs/Lab1.1.in diff --git a/cs2030s/Lab1/inputs/Lab1.2.in b/labs/cs2030s/Lab1/inputs/Lab1.2.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab1.2.in rename to labs/cs2030s/Lab1/inputs/Lab1.2.in diff --git a/cs2030s/Lab1/inputs/Lab1.3.in b/labs/cs2030s/Lab1/inputs/Lab1.3.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab1.3.in rename to labs/cs2030s/Lab1/inputs/Lab1.3.in diff --git a/cs2030s/Lab1/inputs/Lab1.4.in b/labs/cs2030s/Lab1/inputs/Lab1.4.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab1.4.in rename to labs/cs2030s/Lab1/inputs/Lab1.4.in diff --git a/cs2030s/Lab1/inputs/Lab1.5.in b/labs/cs2030s/Lab1/inputs/Lab1.5.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab1.5.in rename to labs/cs2030s/Lab1/inputs/Lab1.5.in diff --git a/cs2030s/Lab1/inputs/Lab2.1.in b/labs/cs2030s/Lab1/inputs/Lab2.1.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.1.in rename to labs/cs2030s/Lab1/inputs/Lab2.1.in diff --git a/cs2030s/Lab1/inputs/Lab2.10.in b/labs/cs2030s/Lab1/inputs/Lab2.10.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.10.in rename to labs/cs2030s/Lab1/inputs/Lab2.10.in diff --git a/cs2030s/Lab1/inputs/Lab2.2.in b/labs/cs2030s/Lab1/inputs/Lab2.2.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.2.in rename to labs/cs2030s/Lab1/inputs/Lab2.2.in diff --git a/cs2030s/Lab1/inputs/Lab2.3.in b/labs/cs2030s/Lab1/inputs/Lab2.3.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.3.in rename to labs/cs2030s/Lab1/inputs/Lab2.3.in diff --git a/cs2030s/Lab1/inputs/Lab2.4.in b/labs/cs2030s/Lab1/inputs/Lab2.4.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.4.in rename to labs/cs2030s/Lab1/inputs/Lab2.4.in diff --git a/cs2030s/Lab1/inputs/Lab2.5.in b/labs/cs2030s/Lab1/inputs/Lab2.5.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.5.in rename to labs/cs2030s/Lab1/inputs/Lab2.5.in diff --git a/cs2030s/Lab1/inputs/Lab2.6.in b/labs/cs2030s/Lab1/inputs/Lab2.6.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.6.in rename to labs/cs2030s/Lab1/inputs/Lab2.6.in diff --git a/cs2030s/Lab1/inputs/Lab2.7.in b/labs/cs2030s/Lab1/inputs/Lab2.7.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.7.in rename to labs/cs2030s/Lab1/inputs/Lab2.7.in diff --git a/cs2030s/Lab1/inputs/Lab2.8.in b/labs/cs2030s/Lab1/inputs/Lab2.8.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.8.in rename to labs/cs2030s/Lab1/inputs/Lab2.8.in diff --git a/cs2030s/Lab1/inputs/Lab2.9.in b/labs/cs2030s/Lab1/inputs/Lab2.9.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab2.9.in rename to labs/cs2030s/Lab1/inputs/Lab2.9.in diff --git a/cs2030s/Lab1/inputs/Lab3.1.in b/labs/cs2030s/Lab1/inputs/Lab3.1.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.1.in rename to labs/cs2030s/Lab1/inputs/Lab3.1.in diff --git a/cs2030s/Lab1/inputs/Lab3.10.in b/labs/cs2030s/Lab1/inputs/Lab3.10.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.10.in rename to labs/cs2030s/Lab1/inputs/Lab3.10.in diff --git a/cs2030s/Lab1/inputs/Lab3.11.in b/labs/cs2030s/Lab1/inputs/Lab3.11.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.11.in rename to labs/cs2030s/Lab1/inputs/Lab3.11.in diff --git a/cs2030s/Lab1/inputs/Lab3.12.in b/labs/cs2030s/Lab1/inputs/Lab3.12.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.12.in rename to labs/cs2030s/Lab1/inputs/Lab3.12.in diff --git a/cs2030s/Lab1/inputs/Lab3.13.in b/labs/cs2030s/Lab1/inputs/Lab3.13.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.13.in rename to labs/cs2030s/Lab1/inputs/Lab3.13.in diff --git a/cs2030s/Lab1/inputs/Lab3.14.in b/labs/cs2030s/Lab1/inputs/Lab3.14.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.14.in rename to labs/cs2030s/Lab1/inputs/Lab3.14.in diff --git a/cs2030s/Lab1/inputs/Lab3.15.in b/labs/cs2030s/Lab1/inputs/Lab3.15.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.15.in rename to labs/cs2030s/Lab1/inputs/Lab3.15.in diff --git a/cs2030s/Lab1/inputs/Lab3.2.in b/labs/cs2030s/Lab1/inputs/Lab3.2.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.2.in rename to labs/cs2030s/Lab1/inputs/Lab3.2.in diff --git a/cs2030s/Lab1/inputs/Lab3.3.in b/labs/cs2030s/Lab1/inputs/Lab3.3.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.3.in rename to labs/cs2030s/Lab1/inputs/Lab3.3.in diff --git a/cs2030s/Lab1/inputs/Lab3.4.in b/labs/cs2030s/Lab1/inputs/Lab3.4.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.4.in rename to labs/cs2030s/Lab1/inputs/Lab3.4.in diff --git a/cs2030s/Lab1/inputs/Lab3.5.in b/labs/cs2030s/Lab1/inputs/Lab3.5.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.5.in rename to labs/cs2030s/Lab1/inputs/Lab3.5.in diff --git a/cs2030s/Lab1/inputs/Lab3.6.in b/labs/cs2030s/Lab1/inputs/Lab3.6.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.6.in rename to labs/cs2030s/Lab1/inputs/Lab3.6.in diff --git a/cs2030s/Lab1/inputs/Lab3.7.in b/labs/cs2030s/Lab1/inputs/Lab3.7.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.7.in rename to labs/cs2030s/Lab1/inputs/Lab3.7.in diff --git a/cs2030s/Lab1/inputs/Lab3.8.in b/labs/cs2030s/Lab1/inputs/Lab3.8.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.8.in rename to labs/cs2030s/Lab1/inputs/Lab3.8.in diff --git a/cs2030s/Lab1/inputs/Lab3.9.in b/labs/cs2030s/Lab1/inputs/Lab3.9.in similarity index 100% rename from cs2030s/Lab1/inputs/Lab3.9.in rename to labs/cs2030s/Lab1/inputs/Lab3.9.in diff --git a/cs2030s/Lab1/outputs/ArrayTest.out b/labs/cs2030s/Lab1/outputs/ArrayTest.out similarity index 100% rename from cs2030s/Lab1/outputs/ArrayTest.out rename to labs/cs2030s/Lab1/outputs/ArrayTest.out diff --git a/cs2030s/Lab1/outputs/Lab1.1.out b/labs/cs2030s/Lab1/outputs/Lab1.1.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab1.1.out rename to labs/cs2030s/Lab1/outputs/Lab1.1.out diff --git a/cs2030s/Lab1/outputs/Lab1.2.out b/labs/cs2030s/Lab1/outputs/Lab1.2.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab1.2.out rename to labs/cs2030s/Lab1/outputs/Lab1.2.out diff --git a/cs2030s/Lab1/outputs/Lab1.3.out b/labs/cs2030s/Lab1/outputs/Lab1.3.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab1.3.out rename to labs/cs2030s/Lab1/outputs/Lab1.3.out diff --git a/cs2030s/Lab1/outputs/Lab1.4.out b/labs/cs2030s/Lab1/outputs/Lab1.4.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab1.4.out rename to labs/cs2030s/Lab1/outputs/Lab1.4.out diff --git a/cs2030s/Lab1/outputs/Lab1.5.out b/labs/cs2030s/Lab1/outputs/Lab1.5.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab1.5.out rename to labs/cs2030s/Lab1/outputs/Lab1.5.out diff --git a/cs2030s/Lab1/outputs/Lab2.1.out b/labs/cs2030s/Lab1/outputs/Lab2.1.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.1.out rename to labs/cs2030s/Lab1/outputs/Lab2.1.out diff --git a/cs2030s/Lab1/outputs/Lab2.10.out b/labs/cs2030s/Lab1/outputs/Lab2.10.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.10.out rename to labs/cs2030s/Lab1/outputs/Lab2.10.out diff --git a/cs2030s/Lab1/outputs/Lab2.2.out b/labs/cs2030s/Lab1/outputs/Lab2.2.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.2.out rename to labs/cs2030s/Lab1/outputs/Lab2.2.out diff --git a/cs2030s/Lab1/outputs/Lab2.3.out b/labs/cs2030s/Lab1/outputs/Lab2.3.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.3.out rename to labs/cs2030s/Lab1/outputs/Lab2.3.out diff --git a/cs2030s/Lab1/outputs/Lab2.4.out b/labs/cs2030s/Lab1/outputs/Lab2.4.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.4.out rename to labs/cs2030s/Lab1/outputs/Lab2.4.out diff --git a/cs2030s/Lab1/outputs/Lab2.5.out b/labs/cs2030s/Lab1/outputs/Lab2.5.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.5.out rename to labs/cs2030s/Lab1/outputs/Lab2.5.out diff --git a/cs2030s/Lab1/outputs/Lab2.6.out b/labs/cs2030s/Lab1/outputs/Lab2.6.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.6.out rename to labs/cs2030s/Lab1/outputs/Lab2.6.out diff --git a/cs2030s/Lab1/outputs/Lab2.7.out b/labs/cs2030s/Lab1/outputs/Lab2.7.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.7.out rename to labs/cs2030s/Lab1/outputs/Lab2.7.out diff --git a/cs2030s/Lab1/outputs/Lab2.8.out b/labs/cs2030s/Lab1/outputs/Lab2.8.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.8.out rename to labs/cs2030s/Lab1/outputs/Lab2.8.out diff --git a/cs2030s/Lab1/outputs/Lab2.9.out b/labs/cs2030s/Lab1/outputs/Lab2.9.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab2.9.out rename to labs/cs2030s/Lab1/outputs/Lab2.9.out diff --git a/cs2030s/Lab1/outputs/Lab3.1.out b/labs/cs2030s/Lab1/outputs/Lab3.1.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.1.out rename to labs/cs2030s/Lab1/outputs/Lab3.1.out diff --git a/cs2030s/Lab1/outputs/Lab3.10.out b/labs/cs2030s/Lab1/outputs/Lab3.10.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.10.out rename to labs/cs2030s/Lab1/outputs/Lab3.10.out diff --git a/cs2030s/Lab1/outputs/Lab3.11.out b/labs/cs2030s/Lab1/outputs/Lab3.11.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.11.out rename to labs/cs2030s/Lab1/outputs/Lab3.11.out diff --git a/cs2030s/Lab1/outputs/Lab3.12.out b/labs/cs2030s/Lab1/outputs/Lab3.12.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.12.out rename to labs/cs2030s/Lab1/outputs/Lab3.12.out diff --git a/cs2030s/Lab1/outputs/Lab3.13.out b/labs/cs2030s/Lab1/outputs/Lab3.13.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.13.out rename to labs/cs2030s/Lab1/outputs/Lab3.13.out diff --git a/cs2030s/Lab1/outputs/Lab3.14.out b/labs/cs2030s/Lab1/outputs/Lab3.14.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.14.out rename to labs/cs2030s/Lab1/outputs/Lab3.14.out diff --git a/cs2030s/Lab1/outputs/Lab3.15.out b/labs/cs2030s/Lab1/outputs/Lab3.15.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.15.out rename to labs/cs2030s/Lab1/outputs/Lab3.15.out diff --git a/cs2030s/Lab1/outputs/Lab3.2.out b/labs/cs2030s/Lab1/outputs/Lab3.2.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.2.out rename to labs/cs2030s/Lab1/outputs/Lab3.2.out diff --git a/cs2030s/Lab1/outputs/Lab3.3.out b/labs/cs2030s/Lab1/outputs/Lab3.3.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.3.out rename to labs/cs2030s/Lab1/outputs/Lab3.3.out diff --git a/cs2030s/Lab1/outputs/Lab3.4.out b/labs/cs2030s/Lab1/outputs/Lab3.4.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.4.out rename to labs/cs2030s/Lab1/outputs/Lab3.4.out diff --git a/cs2030s/Lab1/outputs/Lab3.5.out b/labs/cs2030s/Lab1/outputs/Lab3.5.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.5.out rename to labs/cs2030s/Lab1/outputs/Lab3.5.out diff --git a/cs2030s/Lab1/outputs/Lab3.6.out b/labs/cs2030s/Lab1/outputs/Lab3.6.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.6.out rename to labs/cs2030s/Lab1/outputs/Lab3.6.out diff --git a/cs2030s/Lab1/outputs/Lab3.7.out b/labs/cs2030s/Lab1/outputs/Lab3.7.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.7.out rename to labs/cs2030s/Lab1/outputs/Lab3.7.out diff --git a/cs2030s/Lab1/outputs/Lab3.8.out b/labs/cs2030s/Lab1/outputs/Lab3.8.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.8.out rename to labs/cs2030s/Lab1/outputs/Lab3.8.out diff --git a/cs2030s/Lab1/outputs/Lab3.9.out b/labs/cs2030s/Lab1/outputs/Lab3.9.out similarity index 100% rename from cs2030s/Lab1/outputs/Lab3.9.out rename to labs/cs2030s/Lab1/outputs/Lab3.9.out diff --git a/cs2030s/Lab1/outputs/QueueTest.out b/labs/cs2030s/Lab1/outputs/QueueTest.out similarity index 100% rename from cs2030s/Lab1/outputs/QueueTest.out rename to labs/cs2030s/Lab1/outputs/QueueTest.out diff --git a/cs2030s/Lab1/test.sh b/labs/cs2030s/Lab1/test.sh similarity index 100% rename from cs2030s/Lab1/test.sh rename to labs/cs2030s/Lab1/test.sh diff --git a/cs2030s/Lab4/Action.java b/labs/cs2030s/Lab4/Action.java similarity index 100% rename from cs2030s/Lab4/Action.java rename to labs/cs2030s/Lab4/Action.java diff --git a/cs2030s/Lab4/Actionable.java b/labs/cs2030s/Lab4/Actionable.java similarity index 100% rename from cs2030s/Lab4/Actionable.java rename to labs/cs2030s/Lab4/Actionable.java diff --git a/cs2030s/Lab4/Applicable.java b/labs/cs2030s/Lab4/Applicable.java similarity index 100% rename from cs2030s/Lab4/Applicable.java rename to labs/cs2030s/Lab4/Applicable.java diff --git a/cs2030s/Lab4/CS2030STest.java b/labs/cs2030s/Lab4/CS2030STest.java similarity index 100% rename from cs2030s/Lab4/CS2030STest.java rename to labs/cs2030s/Lab4/CS2030STest.java diff --git a/cs2030s/Lab4/Immutator.java b/labs/cs2030s/Lab4/Immutator.java similarity index 100% rename from cs2030s/Lab4/Immutator.java rename to labs/cs2030s/Lab4/Immutator.java diff --git a/cs2030s/Lab4/Immutatorable.java b/labs/cs2030s/Lab4/Immutatorable.java similarity index 100% rename from cs2030s/Lab4/Immutatorable.java rename to labs/cs2030s/Lab4/Immutatorable.java diff --git a/cs2030s/Lab4/Improbable.java b/labs/cs2030s/Lab4/Improbable.java similarity index 100% rename from cs2030s/Lab4/Improbable.java rename to labs/cs2030s/Lab4/Improbable.java diff --git a/cs2030s/Lab4/IsModEq.java b/labs/cs2030s/Lab4/IsModEq.java similarity index 100% rename from cs2030s/Lab4/IsModEq.java rename to labs/cs2030s/Lab4/IsModEq.java diff --git a/cs2030s/Lab4/Lab4.java b/labs/cs2030s/Lab4/Lab4.java similarity index 100% rename from cs2030s/Lab4/Lab4.java rename to labs/cs2030s/Lab4/Lab4.java diff --git a/cs2030s/Lab4/Lab4.pdf b/labs/cs2030s/Lab4/Lab4.pdf similarity index 100% rename from cs2030s/Lab4/Lab4.pdf rename to labs/cs2030s/Lab4/Lab4.pdf diff --git a/cs2030s/Lab4/MyTest.java b/labs/cs2030s/Lab4/MyTest.java similarity index 100% rename from cs2030s/Lab4/MyTest.java rename to labs/cs2030s/Lab4/MyTest.java diff --git a/cs2030s/Lab4/Print.java b/labs/cs2030s/Lab4/Print.java similarity index 100% rename from cs2030s/Lab4/Print.java rename to labs/cs2030s/Lab4/Print.java diff --git a/cs2030s/Lab4/Probably.java b/labs/cs2030s/Lab4/Probably.java similarity index 100% rename from cs2030s/Lab4/Probably.java rename to labs/cs2030s/Lab4/Probably.java diff --git a/cs2030s/Lab4/Test1.java b/labs/cs2030s/Lab4/Test1.java similarity index 100% rename from cs2030s/Lab4/Test1.java rename to labs/cs2030s/Lab4/Test1.java diff --git a/cs2030s/Lab4/Test2.java b/labs/cs2030s/Lab4/Test2.java similarity index 100% rename from cs2030s/Lab4/Test2.java rename to labs/cs2030s/Lab4/Test2.java diff --git a/cs2030s/Lab4/Test3.java b/labs/cs2030s/Lab4/Test3.java similarity index 100% rename from cs2030s/Lab4/Test3.java rename to labs/cs2030s/Lab4/Test3.java diff --git a/cs2030s/Lab4/Test4.java b/labs/cs2030s/Lab4/Test4.java similarity index 100% rename from cs2030s/Lab4/Test4.java rename to labs/cs2030s/Lab4/Test4.java diff --git a/cs2030s/Lab4/Test5.java b/labs/cs2030s/Lab4/Test5.java similarity index 100% rename from cs2030s/Lab4/Test5.java rename to labs/cs2030s/Lab4/Test5.java diff --git a/cs2030s/Lab4/Test6.java b/labs/cs2030s/Lab4/Test6.java similarity index 100% rename from cs2030s/Lab4/Test6.java rename to labs/cs2030s/Lab4/Test6.java diff --git a/cs2030s/Lab4/TestProbably.java b/labs/cs2030s/Lab4/TestProbably.java similarity index 100% rename from cs2030s/Lab4/TestProbably.java rename to labs/cs2030s/Lab4/TestProbably.java diff --git a/cs2030s/Lab4/inputs/Lab4.1.in b/labs/cs2030s/Lab4/inputs/Lab4.1.in similarity index 100% rename from cs2030s/Lab4/inputs/Lab4.1.in rename to labs/cs2030s/Lab4/inputs/Lab4.1.in diff --git a/cs2030s/Lab4/inputs/Lab4.2.in b/labs/cs2030s/Lab4/inputs/Lab4.2.in similarity index 100% rename from cs2030s/Lab4/inputs/Lab4.2.in rename to labs/cs2030s/Lab4/inputs/Lab4.2.in diff --git a/cs2030s/Lab4/inputs/Lab4.3.in b/labs/cs2030s/Lab4/inputs/Lab4.3.in similarity index 100% rename from cs2030s/Lab4/inputs/Lab4.3.in rename to labs/cs2030s/Lab4/inputs/Lab4.3.in diff --git a/cs2030s/Lab4/inputs/Lab4.4.in b/labs/cs2030s/Lab4/inputs/Lab4.4.in similarity index 100% rename from cs2030s/Lab4/inputs/Lab4.4.in rename to labs/cs2030s/Lab4/inputs/Lab4.4.in diff --git a/cs2030s/Lab4/inputs/Lab4.5.in b/labs/cs2030s/Lab4/inputs/Lab4.5.in similarity index 100% rename from cs2030s/Lab4/inputs/Lab4.5.in rename to labs/cs2030s/Lab4/inputs/Lab4.5.in diff --git a/cs2030s/Lab4/inputs/Lab4.6.in b/labs/cs2030s/Lab4/inputs/Lab4.6.in similarity index 100% rename from cs2030s/Lab4/inputs/Lab4.6.in rename to labs/cs2030s/Lab4/inputs/Lab4.6.in diff --git a/cs2030s/Lab4/outputs/Lab4.1.out b/labs/cs2030s/Lab4/outputs/Lab4.1.out similarity index 100% rename from cs2030s/Lab4/outputs/Lab4.1.out rename to labs/cs2030s/Lab4/outputs/Lab4.1.out diff --git a/cs2030s/Lab4/outputs/Lab4.2.out b/labs/cs2030s/Lab4/outputs/Lab4.2.out similarity index 100% rename from cs2030s/Lab4/outputs/Lab4.2.out rename to labs/cs2030s/Lab4/outputs/Lab4.2.out diff --git a/cs2030s/Lab4/outputs/Lab4.3.out b/labs/cs2030s/Lab4/outputs/Lab4.3.out similarity index 100% rename from cs2030s/Lab4/outputs/Lab4.3.out rename to labs/cs2030s/Lab4/outputs/Lab4.3.out diff --git a/cs2030s/Lab4/outputs/Lab4.4.out b/labs/cs2030s/Lab4/outputs/Lab4.4.out similarity index 100% rename from cs2030s/Lab4/outputs/Lab4.4.out rename to labs/cs2030s/Lab4/outputs/Lab4.4.out diff --git a/cs2030s/Lab4/outputs/Lab4.5.out b/labs/cs2030s/Lab4/outputs/Lab4.5.out similarity index 100% rename from cs2030s/Lab4/outputs/Lab4.5.out rename to labs/cs2030s/Lab4/outputs/Lab4.5.out diff --git a/cs2030s/Lab4/outputs/Lab4.6.out b/labs/cs2030s/Lab4/outputs/Lab4.6.out similarity index 100% rename from cs2030s/Lab4/outputs/Lab4.6.out rename to labs/cs2030s/Lab4/outputs/Lab4.6.out diff --git a/cs2030s/Lab5/CS2030STest.java b/labs/cs2030s/Lab5/CS2030STest.java similarity index 100% rename from cs2030s/Lab5/CS2030STest.java rename to labs/cs2030s/Lab5/CS2030STest.java diff --git a/cs2030s/Lab5/Lab5.h b/labs/cs2030s/Lab5/Lab5.h similarity index 100% rename from cs2030s/Lab5/Lab5.h rename to labs/cs2030s/Lab5/Lab5.h diff --git a/cs2030s/Lab5/Lab5.java b/labs/cs2030s/Lab5/Lab5.java similarity index 100% rename from cs2030s/Lab5/Lab5.java rename to labs/cs2030s/Lab5/Lab5.java diff --git a/cs2030s/Lab5/Lab5.pdf b/labs/cs2030s/Lab5/Lab5.pdf similarity index 100% rename from cs2030s/Lab5/Lab5.pdf rename to labs/cs2030s/Lab5/Lab5.pdf diff --git a/cs2030s/Lab5/Test0.java b/labs/cs2030s/Lab5/Test0.java similarity index 100% rename from cs2030s/Lab5/Test0.java rename to labs/cs2030s/Lab5/Test0.java diff --git a/cs2030s/Lab5/Test1.java b/labs/cs2030s/Lab5/Test1.java similarity index 100% rename from cs2030s/Lab5/Test1.java rename to labs/cs2030s/Lab5/Test1.java diff --git a/cs2030s/Lab5/Test2.java b/labs/cs2030s/Lab5/Test2.java similarity index 100% rename from cs2030s/Lab5/Test2.java rename to labs/cs2030s/Lab5/Test2.java diff --git a/cs2030s/Lab5/Test3.java b/labs/cs2030s/Lab5/Test3.java similarity index 100% rename from cs2030s/Lab5/Test3.java rename to labs/cs2030s/Lab5/Test3.java diff --git a/cs2030s/Lab5/Test4.java b/labs/cs2030s/Lab5/Test4.java similarity index 100% rename from cs2030s/Lab5/Test4.java rename to labs/cs2030s/Lab5/Test4.java diff --git a/cs2030s/Lab5/Test5.java b/labs/cs2030s/Lab5/Test5.java similarity index 100% rename from cs2030s/Lab5/Test5.java rename to labs/cs2030s/Lab5/Test5.java diff --git a/cs2030s/Lab5/cs2030s/fp/Action.java b/labs/cs2030s/Lab5/cs2030s/fp/Action.java similarity index 100% rename from cs2030s/Lab5/cs2030s/fp/Action.java rename to labs/cs2030s/Lab5/cs2030s/fp/Action.java diff --git a/cs2030s/Lab5/cs2030s/fp/Actionable.java b/labs/cs2030s/Lab5/cs2030s/fp/Actionable.java similarity index 100% rename from cs2030s/Lab5/cs2030s/fp/Actionable.java rename to labs/cs2030s/Lab5/cs2030s/fp/Actionable.java diff --git a/cs2030s/Lab5/cs2030s/fp/Actually.java b/labs/cs2030s/Lab5/cs2030s/fp/Actually.java similarity index 100% rename from cs2030s/Lab5/cs2030s/fp/Actually.java rename to labs/cs2030s/Lab5/cs2030s/fp/Actually.java diff --git a/cs2030s/Lab5/cs2030s/fp/Constant.java b/labs/cs2030s/Lab5/cs2030s/fp/Constant.java similarity index 100% rename from cs2030s/Lab5/cs2030s/fp/Constant.java rename to labs/cs2030s/Lab5/cs2030s/fp/Constant.java diff --git a/cs2030s/Lab5/cs2030s/fp/Immutator.java b/labs/cs2030s/Lab5/cs2030s/fp/Immutator.java similarity index 100% rename from cs2030s/Lab5/cs2030s/fp/Immutator.java rename to labs/cs2030s/Lab5/cs2030s/fp/Immutator.java diff --git a/cs2030s/Lab5/cs2030s/fp/Immutatorable.java b/labs/cs2030s/Lab5/cs2030s/fp/Immutatorable.java similarity index 100% rename from cs2030s/Lab5/cs2030s/fp/Immutatorable.java rename to labs/cs2030s/Lab5/cs2030s/fp/Immutatorable.java diff --git a/cs2030s/Lab5/cs2030s/fp/Transformer.java b/labs/cs2030s/Lab5/cs2030s/fp/Transformer.java similarity index 100% rename from cs2030s/Lab5/cs2030s/fp/Transformer.java rename to labs/cs2030s/Lab5/cs2030s/fp/Transformer.java diff --git a/cs2030s/Lab6/And.java b/labs/cs2030s/Lab6/And.java similarity index 100% rename from cs2030s/Lab6/And.java rename to labs/cs2030s/Lab6/And.java diff --git a/cs2030s/Lab6/Bool.java b/labs/cs2030s/Lab6/Bool.java similarity index 100% rename from cs2030s/Lab6/Bool.java rename to labs/cs2030s/Lab6/Bool.java diff --git a/cs2030s/Lab6/CS2030STest.java b/labs/cs2030s/Lab6/CS2030STest.java similarity index 100% rename from cs2030s/Lab6/CS2030STest.java rename to labs/cs2030s/Lab6/CS2030STest.java diff --git a/cs2030s/Lab6/Cond.java b/labs/cs2030s/Lab6/Cond.java similarity index 100% rename from cs2030s/Lab6/Cond.java rename to labs/cs2030s/Lab6/Cond.java diff --git a/cs2030s/Lab6/Lab6.h b/labs/cs2030s/Lab6/Lab6.h similarity index 100% rename from cs2030s/Lab6/Lab6.h rename to labs/cs2030s/Lab6/Lab6.h diff --git a/cs2030s/Lab6/Lab6.java b/labs/cs2030s/Lab6/Lab6.java similarity index 100% rename from cs2030s/Lab6/Lab6.java rename to labs/cs2030s/Lab6/Lab6.java diff --git a/cs2030s/Lab6/Lab6.pdf b/labs/cs2030s/Lab6/Lab6.pdf similarity index 100% rename from cs2030s/Lab6/Lab6.pdf rename to labs/cs2030s/Lab6/Lab6.pdf diff --git a/cs2030s/Lab6/Not.java b/labs/cs2030s/Lab6/Not.java similarity index 100% rename from cs2030s/Lab6/Not.java rename to labs/cs2030s/Lab6/Not.java diff --git a/cs2030s/Lab6/Or.java b/labs/cs2030s/Lab6/Or.java similarity index 100% rename from cs2030s/Lab6/Or.java rename to labs/cs2030s/Lab6/Or.java diff --git a/cs2030s/Lab6/Test1.java b/labs/cs2030s/Lab6/Test1.java similarity index 100% rename from cs2030s/Lab6/Test1.java rename to labs/cs2030s/Lab6/Test1.java diff --git a/cs2030s/Lab6/Test2.java b/labs/cs2030s/Lab6/Test2.java similarity index 100% rename from cs2030s/Lab6/Test2.java rename to labs/cs2030s/Lab6/Test2.java diff --git a/cs2030s/Lab6/Test3.java b/labs/cs2030s/Lab6/Test3.java similarity index 100% rename from cs2030s/Lab6/Test3.java rename to labs/cs2030s/Lab6/Test3.java diff --git a/cs2030s/Lab6/Test4.java b/labs/cs2030s/Lab6/Test4.java similarity index 100% rename from cs2030s/Lab6/Test4.java rename to labs/cs2030s/Lab6/Test4.java diff --git a/cs2030s/Lab6/Test5.java b/labs/cs2030s/Lab6/Test5.java similarity index 100% rename from cs2030s/Lab6/Test5.java rename to labs/cs2030s/Lab6/Test5.java diff --git a/cs2030s/Lab6/cs2030s/fp/Action.java b/labs/cs2030s/Lab6/cs2030s/fp/Action.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Action.java rename to labs/cs2030s/Lab6/cs2030s/fp/Action.java diff --git a/cs2030s/Lab6/cs2030s/fp/Actionable.java b/labs/cs2030s/Lab6/cs2030s/fp/Actionable.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Actionable.java rename to labs/cs2030s/Lab6/cs2030s/fp/Actionable.java diff --git a/cs2030s/Lab6/cs2030s/fp/Actually.java b/labs/cs2030s/Lab6/cs2030s/fp/Actually.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Actually.java rename to labs/cs2030s/Lab6/cs2030s/fp/Actually.java diff --git a/cs2030s/Lab6/cs2030s/fp/Combiner.java b/labs/cs2030s/Lab6/cs2030s/fp/Combiner.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Combiner.java rename to labs/cs2030s/Lab6/cs2030s/fp/Combiner.java diff --git a/cs2030s/Lab6/cs2030s/fp/Constant.java b/labs/cs2030s/Lab6/cs2030s/fp/Constant.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Constant.java rename to labs/cs2030s/Lab6/cs2030s/fp/Constant.java diff --git a/cs2030s/Lab6/cs2030s/fp/Immutator.java b/labs/cs2030s/Lab6/cs2030s/fp/Immutator.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Immutator.java rename to labs/cs2030s/Lab6/cs2030s/fp/Immutator.java diff --git a/cs2030s/Lab6/cs2030s/fp/Immutatorable.java b/labs/cs2030s/Lab6/cs2030s/fp/Immutatorable.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Immutatorable.java rename to labs/cs2030s/Lab6/cs2030s/fp/Immutatorable.java diff --git a/cs2030s/Lab6/cs2030s/fp/Lazy.java b/labs/cs2030s/Lab6/cs2030s/fp/Lazy.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Lazy.java rename to labs/cs2030s/Lab6/cs2030s/fp/Lazy.java diff --git a/cs2030s/Lab6/cs2030s/fp/Memo.java b/labs/cs2030s/Lab6/cs2030s/fp/Memo.java similarity index 100% rename from cs2030s/Lab6/cs2030s/fp/Memo.java rename to labs/cs2030s/Lab6/cs2030s/fp/Memo.java diff --git a/cs2030s/Lab6/docs/And.html b/labs/cs2030s/Lab6/docs/And.html similarity index 100% rename from cs2030s/Lab6/docs/And.html rename to labs/cs2030s/Lab6/docs/And.html diff --git a/cs2030s/Lab6/docs/Bool.html b/labs/cs2030s/Lab6/docs/Bool.html similarity index 100% rename from cs2030s/Lab6/docs/Bool.html rename to labs/cs2030s/Lab6/docs/Bool.html diff --git a/cs2030s/Lab6/docs/Cond.html b/labs/cs2030s/Lab6/docs/Cond.html similarity index 100% rename from cs2030s/Lab6/docs/Cond.html rename to labs/cs2030s/Lab6/docs/Cond.html diff --git a/cs2030s/Lab6/docs/Not.html b/labs/cs2030s/Lab6/docs/Not.html similarity index 100% rename from cs2030s/Lab6/docs/Not.html rename to labs/cs2030s/Lab6/docs/Not.html diff --git a/cs2030s/Lab6/docs/Or.html b/labs/cs2030s/Lab6/docs/Or.html similarity index 100% rename from cs2030s/Lab6/docs/Or.html rename to labs/cs2030s/Lab6/docs/Or.html diff --git a/cs2030s/Lab6/docs/allclasses-index.html b/labs/cs2030s/Lab6/docs/allclasses-index.html similarity index 100% rename from cs2030s/Lab6/docs/allclasses-index.html rename to labs/cs2030s/Lab6/docs/allclasses-index.html diff --git a/cs2030s/Lab6/docs/allclasses.html b/labs/cs2030s/Lab6/docs/allclasses.html similarity index 100% rename from cs2030s/Lab6/docs/allclasses.html rename to labs/cs2030s/Lab6/docs/allclasses.html diff --git a/cs2030s/Lab6/docs/allpackages-index.html b/labs/cs2030s/Lab6/docs/allpackages-index.html similarity index 100% rename from cs2030s/Lab6/docs/allpackages-index.html rename to labs/cs2030s/Lab6/docs/allpackages-index.html diff --git a/cs2030s/Lab6/docs/constant-values.html b/labs/cs2030s/Lab6/docs/constant-values.html similarity index 100% rename from cs2030s/Lab6/docs/constant-values.html rename to labs/cs2030s/Lab6/docs/constant-values.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Action.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Action.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Action.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Action.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Actionable.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Actionable.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Actionable.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Actionable.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Actually.Failure.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Actually.Failure.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Actually.Failure.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Actually.Failure.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Actually.Success.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Actually.Success.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Actually.Success.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Actually.Success.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Actually.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Actually.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Actually.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Actually.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Combiner.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Combiner.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Combiner.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Combiner.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Constant.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Constant.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Constant.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Constant.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Immutator.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Immutator.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Immutator.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Immutator.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Immutatorable.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Immutatorable.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Immutatorable.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Immutatorable.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Lazy.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Lazy.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Lazy.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Lazy.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/Memo.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/Memo.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/Memo.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/Memo.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/package-summary.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/package-summary.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/package-summary.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/package-summary.html diff --git a/cs2030s/Lab6/docs/cs2030s/fp/package-tree.html b/labs/cs2030s/Lab6/docs/cs2030s/fp/package-tree.html similarity index 100% rename from cs2030s/Lab6/docs/cs2030s/fp/package-tree.html rename to labs/cs2030s/Lab6/docs/cs2030s/fp/package-tree.html diff --git a/cs2030s/Lab6/docs/deprecated-list.html b/labs/cs2030s/Lab6/docs/deprecated-list.html similarity index 100% rename from cs2030s/Lab6/docs/deprecated-list.html rename to labs/cs2030s/Lab6/docs/deprecated-list.html diff --git a/cs2030s/Lab6/docs/element-list b/labs/cs2030s/Lab6/docs/element-list similarity index 100% rename from cs2030s/Lab6/docs/element-list rename to labs/cs2030s/Lab6/docs/element-list diff --git a/cs2030s/Lab6/docs/help-doc.html b/labs/cs2030s/Lab6/docs/help-doc.html similarity index 100% rename from cs2030s/Lab6/docs/help-doc.html rename to labs/cs2030s/Lab6/docs/help-doc.html diff --git a/cs2030s/Lab6/docs/index-all.html b/labs/cs2030s/Lab6/docs/index-all.html similarity index 100% rename from cs2030s/Lab6/docs/index-all.html rename to labs/cs2030s/Lab6/docs/index-all.html diff --git a/cs2030s/Lab6/docs/index.html b/labs/cs2030s/Lab6/docs/index.html similarity index 100% rename from cs2030s/Lab6/docs/index.html rename to labs/cs2030s/Lab6/docs/index.html diff --git a/cs2030s/Lab6/docs/jquery/external/jquery/jquery.js b/labs/cs2030s/Lab6/docs/jquery/external/jquery/jquery.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/external/jquery/jquery.js rename to labs/cs2030s/Lab6/docs/jquery/external/jquery/jquery.js diff --git a/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_65_dadada_1x400.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_65_dadada_1x400.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-bg_glass_65_dadada_1x400.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_65_dadada_1x400.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_75_dadada_1x400.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_75_dadada_1x400.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-bg_glass_75_dadada_1x400.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_75_dadada_1x400.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_95_fef1ec_1x400.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_95_fef1ec_1x400.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-bg_glass_95_fef1ec_1x400.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-bg_glass_95_fef1ec_1x400.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-icons_222222_256x240.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-icons_222222_256x240.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-icons_222222_256x240.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-icons_222222_256x240.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-icons_2e83ff_256x240.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-icons_2e83ff_256x240.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-icons_2e83ff_256x240.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-icons_2e83ff_256x240.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-icons_454545_256x240.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-icons_454545_256x240.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-icons_454545_256x240.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-icons_454545_256x240.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-icons_888888_256x240.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-icons_888888_256x240.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-icons_888888_256x240.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-icons_888888_256x240.png diff --git a/cs2030s/Lab6/docs/jquery/images/ui-icons_cd0a0a_256x240.png b/labs/cs2030s/Lab6/docs/jquery/images/ui-icons_cd0a0a_256x240.png similarity index 100% rename from cs2030s/Lab6/docs/jquery/images/ui-icons_cd0a0a_256x240.png rename to labs/cs2030s/Lab6/docs/jquery/images/ui-icons_cd0a0a_256x240.png diff --git a/cs2030s/Lab6/docs/jquery/jquery-3.5.1.js b/labs/cs2030s/Lab6/docs/jquery/jquery-3.5.1.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jquery-3.5.1.js rename to labs/cs2030s/Lab6/docs/jquery/jquery-3.5.1.js diff --git a/cs2030s/Lab6/docs/jquery/jquery-ui.css b/labs/cs2030s/Lab6/docs/jquery/jquery-ui.css similarity index 100% rename from cs2030s/Lab6/docs/jquery/jquery-ui.css rename to labs/cs2030s/Lab6/docs/jquery/jquery-ui.css diff --git a/cs2030s/Lab6/docs/jquery/jquery-ui.js b/labs/cs2030s/Lab6/docs/jquery/jquery-ui.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jquery-ui.js rename to labs/cs2030s/Lab6/docs/jquery/jquery-ui.js diff --git a/cs2030s/Lab6/docs/jquery/jquery-ui.min.css b/labs/cs2030s/Lab6/docs/jquery/jquery-ui.min.css similarity index 100% rename from cs2030s/Lab6/docs/jquery/jquery-ui.min.css rename to labs/cs2030s/Lab6/docs/jquery/jquery-ui.min.css diff --git a/cs2030s/Lab6/docs/jquery/jquery-ui.min.js b/labs/cs2030s/Lab6/docs/jquery/jquery-ui.min.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jquery-ui.min.js rename to labs/cs2030s/Lab6/docs/jquery/jquery-ui.min.js diff --git a/cs2030s/Lab6/docs/jquery/jquery-ui.structure.css b/labs/cs2030s/Lab6/docs/jquery/jquery-ui.structure.css similarity index 100% rename from cs2030s/Lab6/docs/jquery/jquery-ui.structure.css rename to labs/cs2030s/Lab6/docs/jquery/jquery-ui.structure.css diff --git a/cs2030s/Lab6/docs/jquery/jquery-ui.structure.min.css b/labs/cs2030s/Lab6/docs/jquery/jquery-ui.structure.min.css similarity index 100% rename from cs2030s/Lab6/docs/jquery/jquery-ui.structure.min.css rename to labs/cs2030s/Lab6/docs/jquery/jquery-ui.structure.min.css diff --git a/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils-ie.js b/labs/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils-ie.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils-ie.js rename to labs/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils-ie.js diff --git a/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils-ie.min.js b/labs/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils-ie.min.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils-ie.min.js rename to labs/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils-ie.min.js diff --git a/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils.js b/labs/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils.js rename to labs/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils.js diff --git a/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils.min.js b/labs/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils.min.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils.min.js rename to labs/cs2030s/Lab6/docs/jquery/jszip-utils/dist/jszip-utils.min.js diff --git a/cs2030s/Lab6/docs/jquery/jszip/dist/jszip.js b/labs/cs2030s/Lab6/docs/jquery/jszip/dist/jszip.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jszip/dist/jszip.js rename to labs/cs2030s/Lab6/docs/jquery/jszip/dist/jszip.js diff --git a/cs2030s/Lab6/docs/jquery/jszip/dist/jszip.min.js b/labs/cs2030s/Lab6/docs/jquery/jszip/dist/jszip.min.js similarity index 100% rename from cs2030s/Lab6/docs/jquery/jszip/dist/jszip.min.js rename to labs/cs2030s/Lab6/docs/jquery/jszip/dist/jszip.min.js diff --git a/cs2030s/Lab6/docs/member-search-index.js b/labs/cs2030s/Lab6/docs/member-search-index.js similarity index 100% rename from cs2030s/Lab6/docs/member-search-index.js rename to labs/cs2030s/Lab6/docs/member-search-index.js diff --git a/cs2030s/Lab6/docs/member-search-index.zip b/labs/cs2030s/Lab6/docs/member-search-index.zip similarity index 100% rename from cs2030s/Lab6/docs/member-search-index.zip rename to labs/cs2030s/Lab6/docs/member-search-index.zip diff --git a/cs2030s/Lab6/docs/overview-summary.html b/labs/cs2030s/Lab6/docs/overview-summary.html similarity index 100% rename from cs2030s/Lab6/docs/overview-summary.html rename to labs/cs2030s/Lab6/docs/overview-summary.html diff --git a/cs2030s/Lab6/docs/overview-tree.html b/labs/cs2030s/Lab6/docs/overview-tree.html similarity index 100% rename from cs2030s/Lab6/docs/overview-tree.html rename to labs/cs2030s/Lab6/docs/overview-tree.html diff --git a/cs2030s/Lab6/docs/package-search-index.js b/labs/cs2030s/Lab6/docs/package-search-index.js similarity index 100% rename from cs2030s/Lab6/docs/package-search-index.js rename to labs/cs2030s/Lab6/docs/package-search-index.js diff --git a/cs2030s/Lab6/docs/package-search-index.zip b/labs/cs2030s/Lab6/docs/package-search-index.zip similarity index 100% rename from cs2030s/Lab6/docs/package-search-index.zip rename to labs/cs2030s/Lab6/docs/package-search-index.zip diff --git a/cs2030s/Lab6/docs/package-summary.html b/labs/cs2030s/Lab6/docs/package-summary.html similarity index 100% rename from cs2030s/Lab6/docs/package-summary.html rename to labs/cs2030s/Lab6/docs/package-summary.html diff --git a/cs2030s/Lab6/docs/package-tree.html b/labs/cs2030s/Lab6/docs/package-tree.html similarity index 100% rename from cs2030s/Lab6/docs/package-tree.html rename to labs/cs2030s/Lab6/docs/package-tree.html diff --git a/cs2030s/Lab6/docs/resources/glass.png b/labs/cs2030s/Lab6/docs/resources/glass.png similarity index 100% rename from cs2030s/Lab6/docs/resources/glass.png rename to labs/cs2030s/Lab6/docs/resources/glass.png diff --git a/cs2030s/Lab6/docs/resources/x.png b/labs/cs2030s/Lab6/docs/resources/x.png similarity index 100% rename from cs2030s/Lab6/docs/resources/x.png rename to labs/cs2030s/Lab6/docs/resources/x.png diff --git a/cs2030s/Lab6/docs/script.js b/labs/cs2030s/Lab6/docs/script.js similarity index 100% rename from cs2030s/Lab6/docs/script.js rename to labs/cs2030s/Lab6/docs/script.js diff --git a/cs2030s/Lab6/docs/search.js b/labs/cs2030s/Lab6/docs/search.js similarity index 100% rename from cs2030s/Lab6/docs/search.js rename to labs/cs2030s/Lab6/docs/search.js diff --git a/cs2030s/Lab6/docs/stylesheet.css b/labs/cs2030s/Lab6/docs/stylesheet.css similarity index 100% rename from cs2030s/Lab6/docs/stylesheet.css rename to labs/cs2030s/Lab6/docs/stylesheet.css diff --git a/cs2030s/Lab6/docs/type-search-index.js b/labs/cs2030s/Lab6/docs/type-search-index.js similarity index 100% rename from cs2030s/Lab6/docs/type-search-index.js rename to labs/cs2030s/Lab6/docs/type-search-index.js diff --git a/cs2030s/Lab6/docs/type-search-index.zip b/labs/cs2030s/Lab6/docs/type-search-index.zip similarity index 100% rename from cs2030s/Lab6/docs/type-search-index.zip rename to labs/cs2030s/Lab6/docs/type-search-index.zip diff --git a/cs2030s/Lab6/input/Test1.in b/labs/cs2030s/Lab6/input/Test1.in similarity index 100% rename from cs2030s/Lab6/input/Test1.in rename to labs/cs2030s/Lab6/input/Test1.in diff --git a/cs2030s/Lab6/input/Test2.in b/labs/cs2030s/Lab6/input/Test2.in similarity index 100% rename from cs2030s/Lab6/input/Test2.in rename to labs/cs2030s/Lab6/input/Test2.in diff --git a/cs2030s/Lab6/input/Test3.in b/labs/cs2030s/Lab6/input/Test3.in similarity index 100% rename from cs2030s/Lab6/input/Test3.in rename to labs/cs2030s/Lab6/input/Test3.in diff --git a/cs2030s/Lab6/input/Test4.in b/labs/cs2030s/Lab6/input/Test4.in similarity index 100% rename from cs2030s/Lab6/input/Test4.in rename to labs/cs2030s/Lab6/input/Test4.in diff --git a/cs2030s/Lab6/input/Test5.in b/labs/cs2030s/Lab6/input/Test5.in similarity index 100% rename from cs2030s/Lab6/input/Test5.in rename to labs/cs2030s/Lab6/input/Test5.in diff --git a/cs2030s/Lab6/output/Test1.out b/labs/cs2030s/Lab6/output/Test1.out similarity index 100% rename from cs2030s/Lab6/output/Test1.out rename to labs/cs2030s/Lab6/output/Test1.out diff --git a/cs2030s/Lab6/output/Test2.out b/labs/cs2030s/Lab6/output/Test2.out similarity index 100% rename from cs2030s/Lab6/output/Test2.out rename to labs/cs2030s/Lab6/output/Test2.out diff --git a/cs2030s/Lab6/output/Test3.out b/labs/cs2030s/Lab6/output/Test3.out similarity index 100% rename from cs2030s/Lab6/output/Test3.out rename to labs/cs2030s/Lab6/output/Test3.out diff --git a/cs2030s/Lab6/output/Test4.out b/labs/cs2030s/Lab6/output/Test4.out similarity index 100% rename from cs2030s/Lab6/output/Test4.out rename to labs/cs2030s/Lab6/output/Test4.out diff --git a/cs2030s/Lab6/output/Test5.out b/labs/cs2030s/Lab6/output/Test5.out similarity index 100% rename from cs2030s/Lab6/output/Test5.out rename to labs/cs2030s/Lab6/output/Test5.out diff --git a/cs2030s/Lab7/CS2030STest.java b/labs/cs2030s/Lab7/CS2030STest.java similarity index 100% rename from cs2030s/Lab7/CS2030STest.java rename to labs/cs2030s/Lab7/CS2030STest.java diff --git a/cs2030s/Lab7/EagerList.java b/labs/cs2030s/Lab7/EagerList.java similarity index 100% rename from cs2030s/Lab7/EagerList.java rename to labs/cs2030s/Lab7/EagerList.java diff --git a/cs2030s/Lab7/Lab7.h b/labs/cs2030s/Lab7/Lab7.h similarity index 100% rename from cs2030s/Lab7/Lab7.h rename to labs/cs2030s/Lab7/Lab7.h diff --git a/cs2030s/Lab7/Lab7.java b/labs/cs2030s/Lab7/Lab7.java similarity index 100% rename from cs2030s/Lab7/Lab7.java rename to labs/cs2030s/Lab7/Lab7.java diff --git a/cs2030s/Lab7/Lab7.pdf b/labs/cs2030s/Lab7/Lab7.pdf similarity index 100% rename from cs2030s/Lab7/Lab7.pdf rename to labs/cs2030s/Lab7/Lab7.pdf diff --git a/cs2030s/Lab7/MemoList.java b/labs/cs2030s/Lab7/MemoList.java similarity index 100% rename from cs2030s/Lab7/MemoList.java rename to labs/cs2030s/Lab7/MemoList.java diff --git a/cs2030s/Lab7/Test1.java b/labs/cs2030s/Lab7/Test1.java similarity index 100% rename from cs2030s/Lab7/Test1.java rename to labs/cs2030s/Lab7/Test1.java diff --git a/cs2030s/Lab7/Test2.java b/labs/cs2030s/Lab7/Test2.java similarity index 100% rename from cs2030s/Lab7/Test2.java rename to labs/cs2030s/Lab7/Test2.java diff --git a/cs2030s/Lab7/Test3.java b/labs/cs2030s/Lab7/Test3.java similarity index 100% rename from cs2030s/Lab7/Test3.java rename to labs/cs2030s/Lab7/Test3.java diff --git a/cs2030s/Lab7/Test4.java b/labs/cs2030s/Lab7/Test4.java similarity index 100% rename from cs2030s/Lab7/Test4.java rename to labs/cs2030s/Lab7/Test4.java diff --git a/cs2030s/Lab7/Test5.java b/labs/cs2030s/Lab7/Test5.java similarity index 100% rename from cs2030s/Lab7/Test5.java rename to labs/cs2030s/Lab7/Test5.java diff --git a/cs2030s/Lab7/cs2030s/fp/Action.java b/labs/cs2030s/Lab7/cs2030s/fp/Action.java similarity index 100% rename from cs2030s/Lab7/cs2030s/fp/Action.java rename to labs/cs2030s/Lab7/cs2030s/fp/Action.java diff --git a/cs2030s/Lab7/cs2030s/fp/Actionable.java b/labs/cs2030s/Lab7/cs2030s/fp/Actionable.java similarity index 100% rename from cs2030s/Lab7/cs2030s/fp/Actionable.java rename to labs/cs2030s/Lab7/cs2030s/fp/Actionable.java diff --git a/cs2030s/Lab7/cs2030s/fp/Actually.java b/labs/cs2030s/Lab7/cs2030s/fp/Actually.java similarity index 100% rename from cs2030s/Lab7/cs2030s/fp/Actually.java rename to labs/cs2030s/Lab7/cs2030s/fp/Actually.java diff --git a/cs2030s/Lab7/cs2030s/fp/Combiner.java b/labs/cs2030s/Lab7/cs2030s/fp/Combiner.java similarity index 100% rename from cs2030s/Lab7/cs2030s/fp/Combiner.java rename to labs/cs2030s/Lab7/cs2030s/fp/Combiner.java diff --git a/cs2030s/Lab7/cs2030s/fp/Constant.java b/labs/cs2030s/Lab7/cs2030s/fp/Constant.java similarity index 100% rename from cs2030s/Lab7/cs2030s/fp/Constant.java rename to labs/cs2030s/Lab7/cs2030s/fp/Constant.java diff --git a/cs2030s/Lab7/cs2030s/fp/Immutator.java b/labs/cs2030s/Lab7/cs2030s/fp/Immutator.java similarity index 100% rename from cs2030s/Lab7/cs2030s/fp/Immutator.java rename to labs/cs2030s/Lab7/cs2030s/fp/Immutator.java diff --git a/cs2030s/Lab7/cs2030s/fp/Immutatorable.java b/labs/cs2030s/Lab7/cs2030s/fp/Immutatorable.java similarity index 100% rename from cs2030s/Lab7/cs2030s/fp/Immutatorable.java rename to labs/cs2030s/Lab7/cs2030s/fp/Immutatorable.java diff --git a/cs2030s/Lab7/cs2030s/fp/Memo.java b/labs/cs2030s/Lab7/cs2030s/fp/Memo.java similarity index 100% rename from cs2030s/Lab7/cs2030s/fp/Memo.java rename to labs/cs2030s/Lab7/cs2030s/fp/Memo.java diff --git a/cs2030s/Lab7/input/Test1.in b/labs/cs2030s/Lab7/input/Test1.in similarity index 100% rename from cs2030s/Lab7/input/Test1.in rename to labs/cs2030s/Lab7/input/Test1.in diff --git a/cs2030s/Lab7/input/Test2.in b/labs/cs2030s/Lab7/input/Test2.in similarity index 100% rename from cs2030s/Lab7/input/Test2.in rename to labs/cs2030s/Lab7/input/Test2.in diff --git a/cs2030s/Lab7/input/Test3.in b/labs/cs2030s/Lab7/input/Test3.in similarity index 100% rename from cs2030s/Lab7/input/Test3.in rename to labs/cs2030s/Lab7/input/Test3.in diff --git a/cs2030s/Lab7/input/Test4.in b/labs/cs2030s/Lab7/input/Test4.in similarity index 100% rename from cs2030s/Lab7/input/Test4.in rename to labs/cs2030s/Lab7/input/Test4.in diff --git a/cs2030s/Lab7/input/Test5.in b/labs/cs2030s/Lab7/input/Test5.in similarity index 100% rename from cs2030s/Lab7/input/Test5.in rename to labs/cs2030s/Lab7/input/Test5.in diff --git a/cs2030s/Lab7/output/Test1.out b/labs/cs2030s/Lab7/output/Test1.out similarity index 100% rename from cs2030s/Lab7/output/Test1.out rename to labs/cs2030s/Lab7/output/Test1.out diff --git a/cs2030s/Lab7/output/Test2.out b/labs/cs2030s/Lab7/output/Test2.out similarity index 100% rename from cs2030s/Lab7/output/Test2.out rename to labs/cs2030s/Lab7/output/Test2.out diff --git a/cs2030s/Lab7/output/Test3.out b/labs/cs2030s/Lab7/output/Test3.out similarity index 100% rename from cs2030s/Lab7/output/Test3.out rename to labs/cs2030s/Lab7/output/Test3.out diff --git a/cs2030s/Lab7/output/Test4.out b/labs/cs2030s/Lab7/output/Test4.out similarity index 100% rename from cs2030s/Lab7/output/Test4.out rename to labs/cs2030s/Lab7/output/Test4.out diff --git a/cs2030s/Lab7/output/Test5.out b/labs/cs2030s/Lab7/output/Test5.out similarity index 100% rename from cs2030s/Lab7/output/Test5.out rename to labs/cs2030s/Lab7/output/Test5.out diff --git a/cs2030s/Lab8/CS2030STest.java b/labs/cs2030s/Lab8/CS2030STest.java similarity index 100% rename from cs2030s/Lab8/CS2030STest.java rename to labs/cs2030s/Lab8/CS2030STest.java diff --git a/cs2030s/Lab8/Lab8.h b/labs/cs2030s/Lab8/Lab8.h similarity index 100% rename from cs2030s/Lab8/Lab8.h rename to labs/cs2030s/Lab8/Lab8.h diff --git a/cs2030s/Lab8/Lab8.java b/labs/cs2030s/Lab8/Lab8.java similarity index 100% rename from cs2030s/Lab8/Lab8.java rename to labs/cs2030s/Lab8/Lab8.java diff --git a/cs2030s/Lab8/Lab8.pdf b/labs/cs2030s/Lab8/Lab8.pdf similarity index 100% rename from cs2030s/Lab8/Lab8.pdf rename to labs/cs2030s/Lab8/Lab8.pdf diff --git a/cs2030s/Lab8/MyTest.java b/labs/cs2030s/Lab8/MyTest.java similarity index 100% rename from cs2030s/Lab8/MyTest.java rename to labs/cs2030s/Lab8/MyTest.java diff --git a/cs2030s/Lab8/Test1.java b/labs/cs2030s/Lab8/Test1.java similarity index 100% rename from cs2030s/Lab8/Test1.java rename to labs/cs2030s/Lab8/Test1.java diff --git a/cs2030s/Lab8/Test2.java b/labs/cs2030s/Lab8/Test2.java similarity index 100% rename from cs2030s/Lab8/Test2.java rename to labs/cs2030s/Lab8/Test2.java diff --git a/cs2030s/Lab8/Test3.java b/labs/cs2030s/Lab8/Test3.java similarity index 100% rename from cs2030s/Lab8/Test3.java rename to labs/cs2030s/Lab8/Test3.java diff --git a/cs2030s/Lab8/Test4.java b/labs/cs2030s/Lab8/Test4.java similarity index 100% rename from cs2030s/Lab8/Test4.java rename to labs/cs2030s/Lab8/Test4.java diff --git a/cs2030s/Lab8/Test5.java b/labs/cs2030s/Lab8/Test5.java similarity index 100% rename from cs2030s/Lab8/Test5.java rename to labs/cs2030s/Lab8/Test5.java diff --git a/cs2030s/Lab8/Test6.java b/labs/cs2030s/Lab8/Test6.java similarity index 100% rename from cs2030s/Lab8/Test6.java rename to labs/cs2030s/Lab8/Test6.java diff --git a/cs2030s/Lab8/cs2030s/fp/Action.java b/labs/cs2030s/Lab8/cs2030s/fp/Action.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/Action.java rename to labs/cs2030s/Lab8/cs2030s/fp/Action.java diff --git a/cs2030s/Lab8/cs2030s/fp/Actionable.java b/labs/cs2030s/Lab8/cs2030s/fp/Actionable.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/Actionable.java rename to labs/cs2030s/Lab8/cs2030s/fp/Actionable.java diff --git a/cs2030s/Lab8/cs2030s/fp/Actually.java b/labs/cs2030s/Lab8/cs2030s/fp/Actually.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/Actually.java rename to labs/cs2030s/Lab8/cs2030s/fp/Actually.java diff --git a/cs2030s/Lab8/cs2030s/fp/Combiner.java b/labs/cs2030s/Lab8/cs2030s/fp/Combiner.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/Combiner.java rename to labs/cs2030s/Lab8/cs2030s/fp/Combiner.java diff --git a/cs2030s/Lab8/cs2030s/fp/Constant.java b/labs/cs2030s/Lab8/cs2030s/fp/Constant.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/Constant.java rename to labs/cs2030s/Lab8/cs2030s/fp/Constant.java diff --git a/cs2030s/Lab8/cs2030s/fp/Immutator.java b/labs/cs2030s/Lab8/cs2030s/fp/Immutator.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/Immutator.java rename to labs/cs2030s/Lab8/cs2030s/fp/Immutator.java diff --git a/cs2030s/Lab8/cs2030s/fp/Immutatorable.java b/labs/cs2030s/Lab8/cs2030s/fp/Immutatorable.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/Immutatorable.java rename to labs/cs2030s/Lab8/cs2030s/fp/Immutatorable.java diff --git a/cs2030s/Lab8/cs2030s/fp/InfiniteList.java b/labs/cs2030s/Lab8/cs2030s/fp/InfiniteList.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/InfiniteList.java rename to labs/cs2030s/Lab8/cs2030s/fp/InfiniteList.java diff --git a/cs2030s/Lab8/cs2030s/fp/Memo.java b/labs/cs2030s/Lab8/cs2030s/fp/Memo.java similarity index 100% rename from cs2030s/Lab8/cs2030s/fp/Memo.java rename to labs/cs2030s/Lab8/cs2030s/fp/Memo.java diff --git a/cs2030s/Lab9/Lab9a/Lab9a.java b/labs/cs2030s/Lab9/Lab9a/Lab9a.java similarity index 65% rename from cs2030s/Lab9/Lab9a/Lab9a.java rename to labs/cs2030s/Lab9/Lab9a/Lab9a.java index 2263f1d..ff5aae6 100644 --- a/cs2030s/Lab9/Lab9a/Lab9a.java +++ b/labs/cs2030s/Lab9/Lab9a/Lab9a.java @@ -10,25 +10,28 @@ class Lab9a { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); - + // Read matrix 1 Matrix m1 = new Matrix(n); - for (int i=0; i supplier) { @@ -68,6 +71,7 @@ class Matrix { /** * Return a string representation of the matrix, pretty-printed * with each row on a single line. + * * @return The string representation of this matrix. */ public String toString() { @@ -83,14 +87,15 @@ class Matrix { /** * Multiply matrix m with this matrix, return a new result matrix. - * @param m1 The matrix to multiply with. - * @param m2 The matrix to multiply with. - * @param m1Row The starting row of m1. - * @param m1Col The starting col of m1. - * @param m2Row The starting row of m2. - * @param m2Col The starting col of m2. - * @param dimension The dimension of the input (sub)-matrices and the size - * of the output matrix. + * + * @param m1 The matrix to multiply with. + * @param m2 The matrix to multiply with. + * @param m1Row The starting row of m1. + * @param m1Col The starting col of m1. + * @param m2Row The starting row of m2. + * @param m2Col The starting col of m2. + * @param dimension The dimension of the input (sub)-matrices and the size + * of the output matrix. * @return The new matrix. */ public static Matrix nonRecursiveMultiply(Matrix m1, Matrix m2, @@ -108,9 +113,10 @@ class Matrix { } return result; } - + /** * Multiple two matrices non-recursively. + * * @param m1 The matrix to multiply with. * @param m2 The matrix to multiply with. * @return The resulting matrix m1 * m2 @@ -121,14 +127,15 @@ class Matrix { /** * Multiply matrix m with this matrix, return a new result matrix. - * @param m1 The matrix to multiply with. - * @param m2 The matrix to multiply with. - * @param m1Row The starting row of m1. - * @param m1Col The starting col of m1. - * @param m2Row The starting row of m2. - * @param m2Col The starting col of m2. - * @param dimension The dimension of the input (sub)-matrices and the size - * of the output matrix. + * + * @param m1 The matrix to multiply with. + * @param m2 The matrix to multiply with. + * @param m1Row The starting row of m1. + * @param m1Col The starting col of m1. + * @param m2Row The starting row of m2. + * @param m2Col The starting col of m2. + * @param dimension The dimension of the input (sub)-matrices and the size + * of the output matrix. * @return The resulting matrix m1 * m2 */ public static Matrix recursiveMultiply(Matrix m1, Matrix m2, @@ -143,10 +150,8 @@ class Matrix { // multiply then sum the multiplication result. int size = dimension / 2; Matrix result = new Matrix(dimension); - Matrix a11b11 = recursiveMultiply(m1, m2, m1Row, m1Col, m2Row, - m2Col, size); - Matrix a12b21 = recursiveMultiply(m1, m2, m1Row, m1Col + size, - m2Row + size, m2Col, size); + Matrix a11b11 = recursiveMultiply(m1, m2, m1Row, m1Col, m2Row, m2Col, size); + Matrix a12b21 = recursiveMultiply(m1, m2, m1Row, m1Col + size, m2Row + size, m2Col, size); for (int i = 0; i < size; i++) { double[] m1m = a11b11.m[i]; double[] m2m = a12b21.m[i]; @@ -156,10 +161,8 @@ class Matrix { } } - Matrix a11b12 = recursiveMultiply(m1, m2, m1Row, m1Col, m2Row, - m2Col + size, size); - Matrix a12b22 = recursiveMultiply(m1, m2, m1Row, m1Col + size, - m2Row + size, m2Col + size, size); + Matrix a11b12 = recursiveMultiply(m1, m2, m1Row, m1Col, m2Row, m2Col + size, size); + Matrix a12b22 = recursiveMultiply(m1, m2, m1Row, m1Col + size, m2Row + size, m2Col + size, size); for (int i = 0; i < size; i++) { double[] m1m = a11b12.m[i]; double[] m2m = a12b22.m[i]; @@ -169,10 +172,8 @@ class Matrix { } } - Matrix a21b11 = recursiveMultiply(m1, m2, m1Row + size, m1Col, - m2Row, m2Col, size); - Matrix a22b21 = recursiveMultiply(m1, m2, m1Row + size, m1Col + size, - m2Row + size, m2Col, size); + Matrix a21b11 = recursiveMultiply(m1, m2, m1Row + size, m1Col, m2Row, m2Col, size); + Matrix a22b21 = recursiveMultiply(m1, m2, m1Row + size, m1Col + size, m2Row + size, m2Col, size); for (int i = 0; i < size; i++) { double[] m1m = a21b11.m[i]; double[] m2m = a22b21.m[i]; @@ -182,10 +183,8 @@ class Matrix { } } - Matrix a21b12 = recursiveMultiply(m1, m2, m1Row + size, m1Col, - m2Row, m2Col + size, size); - Matrix a22b22 = recursiveMultiply(m1, m2, m1Row + size, m1Col + size, - m2Row + size, m2Col + size, size); + Matrix a21b12 = recursiveMultiply(m1, m2, m1Row + size, m1Col, m2Row, m2Col + size, size); + Matrix a22b22 = recursiveMultiply(m1, m2, m1Row + size, m1Col + size, m2Row + size, m2Col + size, size); for (int i = 0; i < size; i++) { double[] m1m = a21b12.m[i]; double[] m2m = a22b22.m[i]; @@ -200,6 +199,7 @@ class Matrix { /** * Multiple two matrices recursively but sequentially with * divide-and-conquer algorithm. + * * @param m1 The matrix to multiply with. * @param m2 The matrix to multiply with. * @return The resulting matrix m1 * m2 @@ -208,10 +208,10 @@ class Matrix { return Matrix.recursiveMultiply(m1, m2, 0, 0, 0, 0, m1.dimension); } - /** * Multiple two matrices recursively and parallely with * divide-and-conquer algorithm. + * * @param m1 The matrix to multiply with. * @param m2 The matrix to multiply with. * @return The resulting matrix m1 * m2 diff --git a/labs/cs2030s/Lab9/Lab9a/MatrixMultiplication.java b/labs/cs2030s/Lab9/Lab9a/MatrixMultiplication.java new file mode 100644 index 0000000..241433b --- /dev/null +++ b/labs/cs2030s/Lab9/Lab9a/MatrixMultiplication.java @@ -0,0 +1,133 @@ +import java.util.concurrent.ForkJoinTask; +import java.util.concurrent.RecursiveTask; + +class MatrixMultiplication extends RecursiveTask { + + /** The fork threshold. */ + private static final int FORK_THRESHOLD = 1024; // Find a good threshold + + /** The first matrix to multiply with. */ + private final Matrix m1; + + /** The second matrix to multiply with. */ + private final Matrix m2; + + /** The starting row of m1. */ + private final int m1Row; + + /** The starting col of m1. */ + private final int m1Col; + + /** The starting row of m2. */ + private final int m2Row; + + /** The starting col of m2. */ + private final int m2Col; + + /** + * The dimension of the input (sub)-matrices and the size of the output + * matrix. + */ + private int dimension; + + /** + * A constructor for the Matrix Multiplication class. + * + * @param m1 The matrix to multiply with. + * @param m2 The matrix to multiply with. + * @param m1Row The starting row of m1. + * @param m1Col The starting col of m1. + * @param m2Row The starting row of m2. + * @param m2Col The starting col of m2. + * @param dimension The dimension of the input (sub)-matrices and the size + * of the output matrix. + */ + MatrixMultiplication(Matrix m1, Matrix m2, int m1Row, int m1Col, int m2Row, + int m2Col, int dimension) { + this.m1 = m1; + this.m2 = m2; + this.m1Row = m1Row; + this.m1Col = m1Col; + this.m2Row = m2Row; + this.m2Col = m2Col; + this.dimension = dimension; + } + + public static final int THRESHOLD = 2; + + @Override + public Matrix compute() { + // Modify this + if (dimension <= THRESHOLD) { + return Matrix.nonRecursiveMultiply(m1, m2, m1Row, m1Col, m2Row, m2Col, dimension); + } + + int size = dimension / 2; + Matrix result = new Matrix(dimension); + + ForkJoinTask a11b11Fork = new MatrixMultiplication(m1, m2, m1Row, m1Col, m2Row, m2Col, size).fork(); + ForkJoinTask a12b21Fork = new MatrixMultiplication(m1, m2, m1Row, m1Col + size, m2Row + size, m2Col, size) + .fork(); + + ForkJoinTask a11b12Fork = new MatrixMultiplication(m1, m2, m1Row, m1Col, m2Row, m2Col + size, size).fork(); + ForkJoinTask a12b22Fork = new MatrixMultiplication(m1, m2, m1Row, m1Col + size, m2Row + size, m2Col + size, + size).fork(); + + ForkJoinTask a21b11Fork = new MatrixMultiplication(m1, m2, m1Row + size, m1Col, m2Row, m2Col, size).fork(); + ForkJoinTask a22b21Fork = new MatrixMultiplication(m1, m2, m1Row + size, m1Col + size, m2Row + size, m2Col, + size).fork(); + + ForkJoinTask a21b12Fork = new MatrixMultiplication(m1, m2, m1Row + size, m1Col, m2Row, m2Col + size, size) + .fork(); + ForkJoinTask a22b22Fork = new MatrixMultiplication(m1, m2, m1Row + size, m1Col + size, m2Row + size, + m2Col + size, size).fork(); + + Matrix a11b11 = a11b11Fork.join(); + Matrix a12b21 = a12b21Fork.join(); + for (int i = 0; i < size; i++) { + double[] m1m = a11b11.m[i]; + double[] m2m = a12b21.m[i]; + double[] r1m = result.m[i]; + for (int j = 0; j < size; j++) { + r1m[j] = m1m[j] + m2m[j]; + } + } + + Matrix a11b12 = a11b12Fork.join(); + Matrix a12b22 = a12b22Fork.join(); + for (int i = 0; i < size; i++) { + double[] m1m = a11b12.m[i]; + double[] m2m = a12b22.m[i]; + double[] r1m = result.m[i]; + for (int j = 0; j < size; j++) { + r1m[j + size] = m1m[j] + m2m[j]; + } + } + + Matrix a21b11 = a21b11Fork.join(); + Matrix a22b21 = a22b21Fork.join(); + + for (int i = 0; i < size; i++) { + double[] m1m = a21b11.m[i]; + double[] m2m = a22b21.m[i]; + double[] r1m = result.m[i + size]; + for (int j = 0; j < size; j++) { + r1m[j] = m1m[j] + m2m[j]; + } + } + + Matrix a21b12 = a21b12Fork.join(); + Matrix a22b22 = a22b22Fork.join(); + for (int i = 0; i < size; i++) { + double[] m1m = a21b12.m[i]; + double[] m2m = a22b22.m[i]; + double[] r1m = result.m[i + size]; + for (int j = 0; j < size; j++) { + r1m[j + size] = m1m[j] + m2m[j]; + } + } + + return result; + } + +} \ No newline at end of file diff --git a/cs2030s/Lab9/Lab9a/input/Test1.in b/labs/cs2030s/Lab9/Lab9a/input/Test1.in similarity index 100% rename from cs2030s/Lab9/Lab9a/input/Test1.in rename to labs/cs2030s/Lab9/Lab9a/input/Test1.in diff --git a/cs2030s/Lab9/Lab9a/input/Test2.in b/labs/cs2030s/Lab9/Lab9a/input/Test2.in similarity index 100% rename from cs2030s/Lab9/Lab9a/input/Test2.in rename to labs/cs2030s/Lab9/Lab9a/input/Test2.in diff --git a/cs2030s/Lab9/Lab9a/input/Test3.in b/labs/cs2030s/Lab9/Lab9a/input/Test3.in similarity index 100% rename from cs2030s/Lab9/Lab9a/input/Test3.in rename to labs/cs2030s/Lab9/Lab9a/input/Test3.in diff --git a/cs2030s/Lab9/Lab9a/input/Test4.in b/labs/cs2030s/Lab9/Lab9a/input/Test4.in similarity index 100% rename from cs2030s/Lab9/Lab9a/input/Test4.in rename to labs/cs2030s/Lab9/Lab9a/input/Test4.in diff --git a/cs2030s/Lab9/Lab9a/input/Test5.in b/labs/cs2030s/Lab9/Lab9a/input/Test5.in similarity index 100% rename from cs2030s/Lab9/Lab9a/input/Test5.in rename to labs/cs2030s/Lab9/Lab9a/input/Test5.in diff --git a/cs2030s/Lab9/Lab9a/output/Test1.out b/labs/cs2030s/Lab9/Lab9a/output/Test1.out similarity index 100% rename from cs2030s/Lab9/Lab9a/output/Test1.out rename to labs/cs2030s/Lab9/Lab9a/output/Test1.out diff --git a/cs2030s/Lab9/Lab9a/output/Test2.out b/labs/cs2030s/Lab9/Lab9a/output/Test2.out similarity index 100% rename from cs2030s/Lab9/Lab9a/output/Test2.out rename to labs/cs2030s/Lab9/Lab9a/output/Test2.out diff --git a/cs2030s/Lab9/Lab9a/output/Test3.out b/labs/cs2030s/Lab9/Lab9a/output/Test3.out similarity index 100% rename from cs2030s/Lab9/Lab9a/output/Test3.out rename to labs/cs2030s/Lab9/Lab9a/output/Test3.out diff --git a/cs2030s/Lab9/Lab9a/output/Test4.out b/labs/cs2030s/Lab9/Lab9a/output/Test4.out similarity index 100% rename from cs2030s/Lab9/Lab9a/output/Test4.out rename to labs/cs2030s/Lab9/Lab9a/output/Test4.out diff --git a/cs2030s/Lab9/Lab9a/output/Test5.out b/labs/cs2030s/Lab9/Lab9a/output/Test5.out similarity index 100% rename from cs2030s/Lab9/Lab9a/output/Test5.out rename to labs/cs2030s/Lab9/Lab9a/output/Test5.out diff --git a/labs/cs2030s/Lab9/Lab9b/.idea/.gitignore b/labs/cs2030s/Lab9/Lab9b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/labs/cs2030s/Lab9/Lab9b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/labs/cs2030s/Lab9/Lab9b/.idea/vcs.xml b/labs/cs2030s/Lab9/Lab9b/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/labs/cs2030s/Lab9/Lab9b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cs2030s/Lab9/Lab9b/Lab9b.java b/labs/cs2030s/Lab9/Lab9b/Lab9b.java similarity index 100% rename from cs2030s/Lab9/Lab9b/Lab9b.java rename to labs/cs2030s/Lab9/Lab9b/Lab9b.java diff --git a/cs2030s/Lab9/Lab9b/Lab9b.pdf b/labs/cs2030s/Lab9/Lab9b/Lab9b.pdf similarity index 100% rename from cs2030s/Lab9/Lab9b/Lab9b.pdf rename to labs/cs2030s/Lab9/Lab9b/Lab9b.pdf diff --git a/cs2030s/Lab9/Lab9b/Pair.java b/labs/cs2030s/Lab9/Lab9b/Pair.java similarity index 100% rename from cs2030s/Lab9/Lab9b/Pair.java rename to labs/cs2030s/Lab9/Lab9b/Pair.java diff --git a/cs2030s/Lab9/Lab9b/Streaming.java b/labs/cs2030s/Lab9/Lab9b/Streaming.java similarity index 100% rename from cs2030s/Lab9/Lab9b/Streaming.java rename to labs/cs2030s/Lab9/Lab9b/Streaming.java diff --git a/cs2030s/Lab9/Lab9b/input/Test1.in b/labs/cs2030s/Lab9/Lab9b/input/Test1.in similarity index 100% rename from cs2030s/Lab9/Lab9b/input/Test1.in rename to labs/cs2030s/Lab9/Lab9b/input/Test1.in diff --git a/cs2030s/Lab9/Lab9b/input/Test2.in b/labs/cs2030s/Lab9/Lab9b/input/Test2.in similarity index 100% rename from cs2030s/Lab9/Lab9b/input/Test2.in rename to labs/cs2030s/Lab9/Lab9b/input/Test2.in diff --git a/cs2030s/Lab9/Lab9b/input/Test3.in b/labs/cs2030s/Lab9/Lab9b/input/Test3.in similarity index 100% rename from cs2030s/Lab9/Lab9b/input/Test3.in rename to labs/cs2030s/Lab9/Lab9b/input/Test3.in diff --git a/cs2030s/Lab9/Lab9b/input/Test4.in b/labs/cs2030s/Lab9/Lab9b/input/Test4.in similarity index 100% rename from cs2030s/Lab9/Lab9b/input/Test4.in rename to labs/cs2030s/Lab9/Lab9b/input/Test4.in diff --git a/cs2030s/Lab9/Lab9b/output/Test1.out b/labs/cs2030s/Lab9/Lab9b/output/Test1.out similarity index 100% rename from cs2030s/Lab9/Lab9b/output/Test1.out rename to labs/cs2030s/Lab9/Lab9b/output/Test1.out diff --git a/cs2030s/Lab9/Lab9b/output/Test2.out b/labs/cs2030s/Lab9/Lab9b/output/Test2.out similarity index 100% rename from cs2030s/Lab9/Lab9b/output/Test2.out rename to labs/cs2030s/Lab9/Lab9b/output/Test2.out diff --git a/cs2030s/Lab9/Lab9b/output/Test3.out b/labs/cs2030s/Lab9/Lab9b/output/Test3.out similarity index 100% rename from cs2030s/Lab9/Lab9b/output/Test3.out rename to labs/cs2030s/Lab9/Lab9b/output/Test3.out diff --git a/cs2030s/Lab9/Lab9b/output/Test4.out b/labs/cs2030s/Lab9/Lab9b/output/Test4.out similarity index 100% rename from cs2030s/Lab9/Lab9b/output/Test4.out rename to labs/cs2030s/Lab9/Lab9b/output/Test4.out diff --git a/cs2030s/MockPE2/CS2030STest.java b/labs/cs2030s/MockPE2/CS2030STest.java similarity index 100% rename from cs2030s/MockPE2/CS2030STest.java rename to labs/cs2030s/MockPE2/CS2030STest.java diff --git a/cs2030s/MockPE2/Main.java b/labs/cs2030s/MockPE2/Main.java similarity index 100% rename from cs2030s/MockPE2/Main.java rename to labs/cs2030s/MockPE2/Main.java diff --git a/cs2030s/MockPE2/Question.pdf b/labs/cs2030s/MockPE2/Question.pdf similarity index 100% rename from cs2030s/MockPE2/Question.pdf rename to labs/cs2030s/MockPE2/Question.pdf diff --git a/cs2030s/MockPE2/Reader.java b/labs/cs2030s/MockPE2/Reader.java similarity index 100% rename from cs2030s/MockPE2/Reader.java rename to labs/cs2030s/MockPE2/Reader.java diff --git a/cs2030s/MockPE2/Test1.java b/labs/cs2030s/MockPE2/Test1.java similarity index 100% rename from cs2030s/MockPE2/Test1.java rename to labs/cs2030s/MockPE2/Test1.java diff --git a/cs2030s/MockPE2/Test1.jsh b/labs/cs2030s/MockPE2/Test1.jsh similarity index 100% rename from cs2030s/MockPE2/Test1.jsh rename to labs/cs2030s/MockPE2/Test1.jsh diff --git a/cs2030s/MockPE2/Test2.java b/labs/cs2030s/MockPE2/Test2.java similarity index 100% rename from cs2030s/MockPE2/Test2.java rename to labs/cs2030s/MockPE2/Test2.java diff --git a/cs2030s/MockPE2/Test2.jsh b/labs/cs2030s/MockPE2/Test2.jsh similarity index 100% rename from cs2030s/MockPE2/Test2.jsh rename to labs/cs2030s/MockPE2/Test2.jsh diff --git a/cs2030s/MockPE2/Test3.java b/labs/cs2030s/MockPE2/Test3.java similarity index 100% rename from cs2030s/MockPE2/Test3.java rename to labs/cs2030s/MockPE2/Test3.java diff --git a/cs2030s/MockPE2/Test3.jsh b/labs/cs2030s/MockPE2/Test3.jsh similarity index 100% rename from cs2030s/MockPE2/Test3.jsh rename to labs/cs2030s/MockPE2/Test3.jsh diff --git a/cs2030s/MockPE2/Test4.java b/labs/cs2030s/MockPE2/Test4.java similarity index 100% rename from cs2030s/MockPE2/Test4.java rename to labs/cs2030s/MockPE2/Test4.java diff --git a/cs2030s/MockPE2/Test4.jsh b/labs/cs2030s/MockPE2/Test4.jsh similarity index 100% rename from cs2030s/MockPE2/Test4.jsh rename to labs/cs2030s/MockPE2/Test4.jsh diff --git a/cs2030s/MockPE2/Test5.java b/labs/cs2030s/MockPE2/Test5.java similarity index 100% rename from cs2030s/MockPE2/Test5.java rename to labs/cs2030s/MockPE2/Test5.java diff --git a/cs2030s/MockPE2/Test5.jsh b/labs/cs2030s/MockPE2/Test5.jsh similarity index 100% rename from cs2030s/MockPE2/Test5.jsh rename to labs/cs2030s/MockPE2/Test5.jsh diff --git a/cs2030s/MockPE2/Utilities.java b/labs/cs2030s/MockPE2/Utilities.java similarity index 100% rename from cs2030s/MockPE2/Utilities.java rename to labs/cs2030s/MockPE2/Utilities.java diff --git a/cs2030s/MockPE2/cs2030s/fp/Immutator.java b/labs/cs2030s/MockPE2/cs2030s/fp/Immutator.java similarity index 100% rename from cs2030s/MockPE2/cs2030s/fp/Immutator.java rename to labs/cs2030s/MockPE2/cs2030s/fp/Immutator.java diff --git a/cs2030s/MockPE2/cs2030s/fp/Reader.java b/labs/cs2030s/MockPE2/cs2030s/fp/Reader.java similarity index 100% rename from cs2030s/MockPE2/cs2030s/fp/Reader.java rename to labs/cs2030s/MockPE2/cs2030s/fp/Reader.java diff --git a/cs2030s/PE1/Pair.java b/labs/cs2030s/PE1/Pair.java similarity index 100% rename from cs2030s/PE1/Pair.java rename to labs/cs2030s/PE1/Pair.java diff --git a/cs2030s/PE1/Queueable.java b/labs/cs2030s/PE1/Queueable.java similarity index 100% rename from cs2030s/PE1/Queueable.java rename to labs/cs2030s/PE1/Queueable.java diff --git a/cs2030s/PE1/Sequeue.java b/labs/cs2030s/PE1/Sequeue.java similarity index 100% rename from cs2030s/PE1/Sequeue.java rename to labs/cs2030s/PE1/Sequeue.java diff --git a/cs2030s/PE2 2021-2022/CS2030STest.java b/labs/cs2030s/PE2 2021-2022/CS2030STest.java similarity index 100% rename from cs2030s/PE2 2021-2022/CS2030STest.java rename to labs/cs2030s/PE2 2021-2022/CS2030STest.java diff --git a/cs2030s/PE2 2021-2022/Query.java b/labs/cs2030s/PE2 2021-2022/Query.java similarity index 100% rename from cs2030s/PE2 2021-2022/Query.java rename to labs/cs2030s/PE2 2021-2022/Query.java diff --git a/cs2030s/PE2 2021-2022/Question.pdf b/labs/cs2030s/PE2 2021-2022/Question.pdf similarity index 100% rename from cs2030s/PE2 2021-2022/Question.pdf rename to labs/cs2030s/PE2 2021-2022/Question.pdf diff --git a/cs2030s/PE2 2021-2022/StreamAPI.md b/labs/cs2030s/PE2 2021-2022/StreamAPI.md similarity index 100% rename from cs2030s/PE2 2021-2022/StreamAPI.md rename to labs/cs2030s/PE2 2021-2022/StreamAPI.md diff --git a/cs2030s/PE2 2021-2022/Test1.java b/labs/cs2030s/PE2 2021-2022/Test1.java similarity index 100% rename from cs2030s/PE2 2021-2022/Test1.java rename to labs/cs2030s/PE2 2021-2022/Test1.java diff --git a/cs2030s/PE2 2021-2022/Test2.java b/labs/cs2030s/PE2 2021-2022/Test2.java similarity index 100% rename from cs2030s/PE2 2021-2022/Test2.java rename to labs/cs2030s/PE2 2021-2022/Test2.java diff --git a/cs2030s/PE2 2021-2022/Test3.java b/labs/cs2030s/PE2 2021-2022/Test3.java similarity index 100% rename from cs2030s/PE2 2021-2022/Test3.java rename to labs/cs2030s/PE2 2021-2022/Test3.java diff --git a/cs2030s/PE2 2021-2022/Test4.java b/labs/cs2030s/PE2 2021-2022/Test4.java similarity index 100% rename from cs2030s/PE2 2021-2022/Test4.java rename to labs/cs2030s/PE2 2021-2022/Test4.java diff --git a/cs2030s/PE2 2021-2022/cs2030s/fp/BooleanCondition.java b/labs/cs2030s/PE2 2021-2022/cs2030s/fp/BooleanCondition.java similarity index 100% rename from cs2030s/PE2 2021-2022/cs2030s/fp/BooleanCondition.java rename to labs/cs2030s/PE2 2021-2022/cs2030s/fp/BooleanCondition.java diff --git a/cs2030s/PE2 2021-2022/cs2030s/fp/Either.java b/labs/cs2030s/PE2 2021-2022/cs2030s/fp/Either.java similarity index 100% rename from cs2030s/PE2 2021-2022/cs2030s/fp/Either.java rename to labs/cs2030s/PE2 2021-2022/cs2030s/fp/Either.java diff --git a/cs2030s/PE2 2021-2022/cs2030s/fp/Transformer.java b/labs/cs2030s/PE2 2021-2022/cs2030s/fp/Transformer.java similarity index 100% rename from cs2030s/PE2 2021-2022/cs2030s/fp/Transformer.java rename to labs/cs2030s/PE2 2021-2022/cs2030s/fp/Transformer.java diff --git a/cs2030s/PE2/PE2.pdf b/labs/cs2030s/PE2/PE2.pdf similarity index 100% rename from cs2030s/PE2/PE2.pdf rename to labs/cs2030s/PE2/PE2.pdf diff --git a/cs2030s/PE2/plab0124/CS2030STest.java b/labs/cs2030s/PE2/plab0124/CS2030STest.java similarity index 100% rename from cs2030s/PE2/plab0124/CS2030STest.java rename to labs/cs2030s/PE2/plab0124/CS2030STest.java diff --git a/cs2030s/PE2/plab0124/MyTest.java b/labs/cs2030s/PE2/plab0124/MyTest.java similarity index 100% rename from cs2030s/PE2/plab0124/MyTest.java rename to labs/cs2030s/PE2/plab0124/MyTest.java diff --git a/cs2030s/PE2/plab0124/Pair.java b/labs/cs2030s/PE2/plab0124/Pair.java similarity index 100% rename from cs2030s/PE2/plab0124/Pair.java rename to labs/cs2030s/PE2/plab0124/Pair.java diff --git a/cs2030s/PE2/plab0124/Streaming.java b/labs/cs2030s/PE2/plab0124/Streaming.java similarity index 100% rename from cs2030s/PE2/plab0124/Streaming.java rename to labs/cs2030s/PE2/plab0124/Streaming.java diff --git a/cs2030s/PE2/plab0124/Test1.java b/labs/cs2030s/PE2/plab0124/Test1.java similarity index 100% rename from cs2030s/PE2/plab0124/Test1.java rename to labs/cs2030s/PE2/plab0124/Test1.java diff --git a/cs2030s/PE2/plab0124/Test1.jsh b/labs/cs2030s/PE2/plab0124/Test1.jsh similarity index 100% rename from cs2030s/PE2/plab0124/Test1.jsh rename to labs/cs2030s/PE2/plab0124/Test1.jsh diff --git a/cs2030s/PE2/plab0124/Test2.java b/labs/cs2030s/PE2/plab0124/Test2.java similarity index 100% rename from cs2030s/PE2/plab0124/Test2.java rename to labs/cs2030s/PE2/plab0124/Test2.java diff --git a/cs2030s/PE2/plab0124/Test2.jsh b/labs/cs2030s/PE2/plab0124/Test2.jsh similarity index 100% rename from cs2030s/PE2/plab0124/Test2.jsh rename to labs/cs2030s/PE2/plab0124/Test2.jsh diff --git a/cs2030s/PE2/plab0124/Test3.java b/labs/cs2030s/PE2/plab0124/Test3.java similarity index 100% rename from cs2030s/PE2/plab0124/Test3.java rename to labs/cs2030s/PE2/plab0124/Test3.java diff --git a/cs2030s/PE2/plab0124/Test3.jsh b/labs/cs2030s/PE2/plab0124/Test3.jsh similarity index 100% rename from cs2030s/PE2/plab0124/Test3.jsh rename to labs/cs2030s/PE2/plab0124/Test3.jsh diff --git a/cs2030s/PE2/plab0124/Test4.java b/labs/cs2030s/PE2/plab0124/Test4.java similarity index 100% rename from cs2030s/PE2/plab0124/Test4.java rename to labs/cs2030s/PE2/plab0124/Test4.java diff --git a/cs2030s/PE2/plab0124/Test4.jsh b/labs/cs2030s/PE2/plab0124/Test4.jsh similarity index 100% rename from cs2030s/PE2/plab0124/Test4.jsh rename to labs/cs2030s/PE2/plab0124/Test4.jsh diff --git a/cs2030s/PE2/plab0124/Test5.java b/labs/cs2030s/PE2/plab0124/Test5.java similarity index 100% rename from cs2030s/PE2/plab0124/Test5.java rename to labs/cs2030s/PE2/plab0124/Test5.java diff --git a/cs2030s/PE2/plab0124/Test5.jsh b/labs/cs2030s/PE2/plab0124/Test5.jsh similarity index 100% rename from cs2030s/PE2/plab0124/Test5.jsh rename to labs/cs2030s/PE2/plab0124/Test5.jsh diff --git a/cs2030s/PE2/plab0124/Test6.jsh b/labs/cs2030s/PE2/plab0124/Test6.jsh similarity index 100% rename from cs2030s/PE2/plab0124/Test6.jsh rename to labs/cs2030s/PE2/plab0124/Test6.jsh diff --git a/cs2030s/PE2/plab0124/Test7.java b/labs/cs2030s/PE2/plab0124/Test7.java similarity index 100% rename from cs2030s/PE2/plab0124/Test7.java rename to labs/cs2030s/PE2/plab0124/Test7.java diff --git a/cs2030s/PE2/plab0124/Test7.jsh b/labs/cs2030s/PE2/plab0124/Test7.jsh similarity index 100% rename from cs2030s/PE2/plab0124/Test7.jsh rename to labs/cs2030s/PE2/plab0124/Test7.jsh diff --git a/cs2030s/PE2/plab0124/cs2030s/fp/Immutator.java b/labs/cs2030s/PE2/plab0124/cs2030s/fp/Immutator.java similarity index 100% rename from cs2030s/PE2/plab0124/cs2030s/fp/Immutator.java rename to labs/cs2030s/PE2/plab0124/cs2030s/fp/Immutator.java diff --git a/cs2030s/PE2/plab0124/cs2030s/fp/Saveable.java b/labs/cs2030s/PE2/plab0124/cs2030s/fp/Saveable.java similarity index 100% rename from cs2030s/PE2/plab0124/cs2030s/fp/Saveable.java rename to labs/cs2030s/PE2/plab0124/cs2030s/fp/Saveable.java