%% Style file for common math symbols

\NeedsTeXFormat{LaTeX2e}

% \usepackage{times}
\usepackage{latexsym}
\usepackage{bbm}
\usepackage[small,bf]{caption2}
\usepackage{graphics}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amsopn}
\usepackage{url}
%\usepackage{hyperref}


%% Page size

\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\textwidth}{6.5in}
\setlength{\topmargin}{0in}
\setlength{\textheight}{8.5in}

%% Misc

% Some hacks to make HTML happier.
\newcommand{\vskipargs}[1]{\vskip #1}
\newcommand{\newproc}{\hrule\vskipargs{1ex plus 0.1ex minus 0.1ex}}

% Tilde for webstuff
\newcommand{\webtilde}{\raisebox{-.8ex}\~}

% Comment out chunks.
\newcommand{\punt}[1]{}
\newcommand{\remove}[1]{}

% Footnote commands.
\newcommand{\footnotenonumber}[1]{{\def\thempfn{}\footnotetext{#1}}}
\newcommand{\footnotetight}[1]{\footnote{\renewcommand\baselinestretch{1}\footnotesize #1}}

% Commands for handout headers
\newcommand{\handout}[5]{
%   \renewcommand{\thepage}{#1-\arabic{page}}
   \noindent
   \begin{center}
   \framebox{
    \vbox{
        \hbox to 5.78in { {\bf CS861: Theoretical Foundations of Machine
Learning} \hfill #5 }
       \vspace{1mm}
        \hbox to 5.78in { {University of Wisconsin--Madison, Fall 2024}  \hfill }
       \vspace{6mm}
       \hbox to 5.78in { {\Large \hfill #2  \hfill} }
       \vspace{4mm}
       \hbox to 5.78in { {\it #3 \hfill #4} }
     }
   }
   \end{center}
   \vspace*{4mm}
   \newcommand{\lecturenum}{#1}
   \addcontentsline{toc}{chapter}{Lecture #1 -- #2}
}

\newcommand{\lecturetitle}[4]{\handout{#1}{#2}{Lecturer: Kirthevasan Kandasamy
  }{Scribed by: #3}{Lecture #1 - #4}}
\newcommand{\guestlecturetitle}[5]{\handout{#1}{#2}{Guest lecturer:
    #4}{Scribed by: #3}{Lecture #1 - #5}}

% Assorted theorem/proof environments

% \newtheorem{theorem}{Theorem}[chapter]
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
\newtheorem{lemma}{Lemma}
\newtheorem{observation}{Observation}
\newtheorem{proposition}{Proposition}
\newtheorem{definition}{Definition}
\newtheorem{claim}{Claim}
\newtheorem{fact}{Fact}
\newtheorem{assumption}{Assumption}

\renewenvironment{proof}{\noindent{\bf Proof}\hspace*{1em}}{\qed\bigskip\\}
\newenvironment{proof-sketch}{\noindent{\bf Sketch of Proof}\hspace*{1em}}{\qed\bigskip\\}
\newenvironment{proof-idea}{\noindent{\bf Proof Idea}\hspace*{1em}}{\qed\bigskip\\}
\newenvironment{proof-of-lemma}[1]{\noindent{\bf Proof of Lemma #1}\hspace*{1em}}{\qed\bigskip\\}
\newenvironment{proof-attempt}{\noindent{\bf Proof Attempt}\hspace*{1em}}{\qed\bigskip\\}
\newenvironment{proofof}[1]{\noindent{\bf Proof} of #1:\hspace*{1em}}{\qed\bigskip\\}
\newenvironment{remark}{\noindent{\bf Remark}\hspace*{1em}}{\bigskip}

% \newcounter{example}
% \newenvironment{example}[1][]
% {\refstepcounter{example}{\noindent\bf Example~\arabic{example}.~#1}}{}

\newcounter{example}
\newenvironment{example}
 {\@ifnextchar[{\examplearg}{\examplenarg}}{}

\def\examplearg[#1]{\refstepcounter{theorem}\noindent{\bf Example~\arabic{theorem}}~(#1){\bf .}~}
\def\examplenarg{\refstepcounter{theorem}\noindent{\bf Example~\arabic{theorem}.}~}

\newenvironment{exercise}
 {\@ifnextchar[{\exercisearg}{\exercisenarg}}{}

\def\exercisearg[#1]{\refstepcounter{theorem}\noindent{\bf Exercise~\arabic{theorem}}~(#1){\bf .}~}
\def\exercisenarg{\refstepcounter{theorem}\noindent{\bf Exercise~\arabic{theorem}.}~}

\renewcommand{\theexample}{\arabic{example}}

% Figure/Tables Stuff

\makeatletter
\def\fnum@figure{{\bf Figure \thefigure}}
\def\fnum@table{{\bf Table \thetable}}
\long\def\@mycaption#1[#2]#3{\addcontentsline{\csname
  ext@#1\endcsname}{#1}{\protect\numberline{\csname
  the#1\endcsname}{\ignorespaces #2}}\par
  \begingroup
    \@parboxrestore
    \small
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}
\def\mycaption{\refstepcounter\@captype \@dblarg{\@mycaption\@captype}}
\makeatother

\newcommand{\figcaption}[1]{\mycaption[]{#1}}
\newcommand{\tabcaption}[1]{\mycaption[]{#1}}
\newcommand{\head}[1]{\chapter[Lecture \##1]{}}
\newcommand{\mathify}[1]{\ifmmode{#1}\else\mbox{$#1$}\fi}
\renewcommand{\Pr}[1]{\mathify{\mbox{Pr}\left[#1\right]}}
\newcommand{\Exp}[1]{\mathify{\mbox{Exp}\left[#1\right]}}
\newcommand{\bigO}O
\newcommand{\set}[1]{\mathify{\left\{ #1 \right\}}}
\def\half{\frac{1}{2}}

\def\implies{\Rightarrow}
\def\sizeof#1{\left| #1\right|}
\def\setof#1{\left\{ #1\right\}  }

%% Math Stuff, Symbols
\newcommand{\field}[1]{\mathbb{#1}}
\newcommand{\N}{\field{N}} % natural numbers
\newcommand{\R}{\field{R}} % real numbers
\newcommand{\Z}{\field{Z}} % integers
\renewcommand{\Re}{\R} % reals
\newcommand{\1}{{\bf 1}} % vector of all 1's
\newcommand{\I}[1]{\mathbb{I}_{\left\{#1\right\}}} % indicator function
% \newcommand{\tends}{{\rightarrow}} % arrow for limits
% \newcommand{\ra}{{\rightarrow}} % abbreviation for right arrow
% \newcommand{\PR}{\mathsf{P}} % probability
%\newcommand{\E}{\mathsf{E}} % expectation
% \newcommand{\subjectto}{\mbox{\rm subject to}} % subject to
\DeclareMathOperator{\E}{\mathbb{E}} % expectation
\DeclareMathOperator{\PR}{\mathbb{P}} % probability
\DeclareMathOperator{\subjectto}{subject\ to} % probability
\DeclareMathOperator{\tr}{\mathsf{tr}} 
\newcommand{\norm}[1]{\left\|#1\right\|}
\newcommand{\card}[1]{\left|#1\right|}
%% math operators
% \newcommand\argmin{\mathop{\mbox{{\rm argmin}}}\limits}
% \newcommand\argmax{\mathop{\mbox{{\rm argmax}}}\limits}
% \newcommand\maximize{\mathop{\mbox{{\rm maximize}}}\limits}
% \newcommand\minimize{\mathop{\mbox{{\rm minimize}}}\limits}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\maximize}{maximize}
\DeclareMathOperator*{\minimize}{minimize}


\newenvironment{lecture}[4]{\begin{document}
    \lecturetitle{#1}{#2}{#3}{#4}}{}

\newcommand{\theend}{\end{document}}

\newcommand{\kkcomment}[1]{\textcolor{red}{(#1 --KK)}}
