%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% TEXT COMMANDS %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Respectivement e.g. "mon bras \resp[gauche][droit] est \resp[bleu][vert]"
\newcommand{\resp}[2]{#1 [resp. #2]}
% Sans le 'resp.' où c'est clair
\newcommand{\sresp}[2]{#1 [#2]}
% Semantically equivalent to \resp{}{#1}, but fixes spacing issue
\newcommand{\respOne}[1]{[resp. #1]}
\newcommand{\srespOne}[1]{[#1]}

\newcommand{\english}[1]{\textit{#1}}

% Nouveaux termes définit
\newcommand{\defin}[1]{\textit{#1}}

\newcommand{\Ssi}{Si et seulement si}
\newcommand{\ssi}{si et seulement si}
\newcommand{\Spdg}{Sans perte de généralité}
\newcommand{\spdg}{perte de généralité}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% ENV. PREUVE / THÉORÊME %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Proof

\renewcommand{\qedsymbol}{{\color{white}gg}$\square$} % hi hi hi :)

\newenvironment{subproof}
{% Before
  \renewcommand{\qedsymbol}{$\square$}
  \begin{proof}[Mini-Démonstration]
  \leftskip=1cm
}
{% After
  \end{proof}
}

%% TODO

\newtheoremstyle{mytodostyle} % name
    {\topsep}                 % Space above
    {\topsep}                 % Space below
    {\color{gray}}            % Body font
    {}                        % Indent amount
    {\color{gray}}            % Theorem head font
    {.}                       % Punctuation after theorem head
    {.5em}                    % Space after theorem head
    {}  % Theorem head spec (can be left empty, meaning ‘normal’)

\theoremstyle{mytodostyle}
\newtheorem{todo}{TODO}

%% Algo

\algrenewcommand\algorithmicprocedure{\textbf{procédure}}
\algrenewcommand\algorithmicloop{\textbf{boucler}}
\algrenewcommand\algorithmicwhile{\textbf{tant que}}
\algrenewcommand\algorithmicdo{\textbf{faire}}
\algrenewcommand\algorithmicforall{\textbf{pour chaque}}
\algrenewcommand\algorithmicfor{\textbf{pour}}
\algrenewcommand\algorithmicrepeat{\textbf{faire}}
\algrenewcommand\algorithmicuntil{\textbf{jusqu'à}}
\algrenewcommand\algorithmicif{\textbf{si}}
\algrenewcommand\algorithmicelse{\textbf{sinon}}
\algrenewcommand\algorithmicthen{\textbf{alors}}
\algrenewcommand\algorithmicend{\textbf{fin}}
\algrenewcommand\algorithmicreturn{\textbf{renvoie}}
\newcommand{\Break}{\State \textbf{sortir boucle} }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% "META" MATH COMMANDS %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Auto-sized breakable paired delimiters

\newcommand{\LRSpacedParenthesis}[2]{\left(\vphantom{#1} #2 \right. #1 \left. #2 \vphantom{#1}\right)}
\newcommand{\LRSpacedCurly}[2]{\left\{\vphantom{#1} #2 \right. #1 \left. #2 \vphantom{#1}\right\}}
\newcommand{\LRSpacedBracket}[2]{\left[\vphantom{#1} #2 \right. #1 \left. #2 \vphantom{#1}\right]}
\newcommand{\LRSpacedPipe}[2]{\left|\vphantom{#1} #2 \right. #1 \left. #2 \vphantom{#1}\right|}
\newcommand{\LRSpacedAngle}[2]{\left\langle\vphantom{#1} #2 \right. #1 \left. #2 \vphantom{#1}\right\rangle}
\newcommand{\LRSpacedCeil}[2]{\left\lceil\vphantom{#1} #2 \right. #1 \left. #2 \vphantom{#1}\right\rceil}
\newcommand{\LRSpacedFloor}[2]{\left\lfloor\vphantom{#1} #2 \right. #1 \left. #2 \vphantom{#1}\right\rfloor}

%% Variables arguments paired delimiters
\makeatletter
\newcommand{\tupl}[1]{\left(\,#1\checknexttupl}
\newcommand{\checknexttupl}{\@ifnextchar\bgroup{\gobblenexttupl}{\,\right)}}
\newcommand{\gobblenexttupl}[1]{\,,\,#1\@ifnextchar\bgroup{\checknexttupl}{\,\right)}}
\makeatother

\makeatletter
\newcommand{\fof}[2]{#1\left(\,#2\checknextfof}
\newcommand{\checknextfof}{\@ifnextchar\bgroup{\gobblenextfof}{\,\right)}}
\newcommand{\gobblenextfof}[1]{\,,\,#1\@ifnextchar\bgroup{\checknextfof}{\,\right)}}
\makeatother

\makeatletter
\newcommand{\setof}[1]{\left\{\,#1\checknextset}
\newcommand{\checknextset}{\@ifnextchar\bgroup{\gobblenextset}{\,\right\}}}
\newcommand{\gobblenextset}[1]{\,,\,#1\@ifnextchar\bgroup{\checknextset}{\,\right\}}}
\makeatother

\makeatletter
\newcommand{\lst}[1]{\,#1\checknextlst}
\newcommand{\checknextlst}{\@ifnextchar\bgroup{\gobblenextlst}{\,}}
\newcommand{\gobblenextlst}[1]{\,,\,#1\@ifnextchar\bgroup{\checknextlst}{\,}}
\makeatother

\makeatletter
\newcommand{\codeof}[1]{\left\langle\,#1\checknextcodeof}
\newcommand{\checknextcodeof}{\@ifnextchar\bgroup{\gobblenextcodeof}{\,\right\rangle}}
\newcommand{\gobblenextcodeof}[1]{\,,\,#1\@ifnextchar\bgroup{\checknextcodeof}{\,\right\rangle}}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%% MATH COMMANDS %%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Semantic paired delimiters

\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

% General-purpose parenthesis for grouping part of an equation
\newcommand{\paren}[1]{\LRSpacedParenthesis{#1}{}}

% The function input can be long, it needs to be breakable
\newcommand{\fofZero}[1]{#1(\hspace{.1em})}
\newcommand{\fofOne}[2]{#1\LRSpacedParenthesis{#2}{\!}}
\newcommand{\fofTwo}[3]{#1\LRSpacedParenthesis{#2\,,\,#3}{\!}}
\newcommand{\fofThree}[4]{#1\LRSpacedParenthesis{#2\,,\,#3\,,\,#4}{\!}}

% Used for tuples (usually, each argument is 1 or 2 symbols)
\newcommand{\tuplOne}[1]{\LRSpacedParenthesis{#1}{\!}}
\newcommand{\tuplTwo}[2]{\LRSpacedParenthesis{#1\,,\,#2}{\!}}
\newcommand{\tuplThree}[3]{\LRSpacedParenthesis{#1\,,\,#2\,,\,#3}{\!}}
\newcommand{\tuplFour}[4]{\LRSpacedParenthesis{#1\,,\,#2\,,\,#3\,,\,#4}{\!}}
\newcommand{\tuplFive}[5]{\LRSpacedParenthesis{#1\,,\,#2\,,\,#3\,,\,#4\,,\,#5}{\!}}
% just for that damn figure caption that won't work with generic \tupl
\newcommand{\tuplSeven}[7]{\LRSpacedParenthesis{#1\,,\,#2\,,\,#3\,,\,#4\,,\,#5\,,\,#6\,,\,#7}{\!}}

% Set (usually enumerates arguments that are 1 or 2 symbols long)
\newcommand{\setOne}[1]{\LRSpacedCurly{#1}{\!}}
\newcommand{\setTwo}[2]{\LRSpacedCurly{#1\,,\,#2}{\!}}
\newcommand{\setThree}[3]{\LRSpacedCurly{#1\,,\,#2\,,\,#3}{\!}}
\newcommand{\setFour}[4]{\LRSpacedCurly{#1\,,\,#2\,,\,#3\,,\,#4}{\!}}
\newcommand{\setFive}[5]{\LRSpacedCurly{#1\,,\,#2\,,\,#3\,,\,#4\,,\,#5}{\!}}

% Set with a : in the middle (second argument can be long)
\newcommand{\setcond}[2]{\LRSpacedCurly{#1\,:\,#2}{}}

\newcommand{\lstTwo}[2]{\hspace{.08em} #1 , \hspace{.08em} #2 \hspace{.08em}}
\newcommand{\lstThree}[3]{\hspace{.08em} #1 , \hspace{.08em} #2 , \hspace{.08em} #3 \hspace{.08em}}
\newcommand{\lstFour}[4]{\hspace{.08em} #1 , \hspace{.08em} #2 , \hspace{.08em} #3 , \hspace{.08em} #4 \hspace{.08em}}
\newcommand{\lstFive}[5]{\hspace{.08em} #1 , \hspace{.08em} #2 , \hspace{.08em} #3 , \hspace{.08em} #4 , \hspace{.08em} #5 \hspace{.08em}}

\newcommand{\opChainFour}[5]{\hspace{.08em} #2 \hspace{.08em} #1 \hspace{.08em} #3 \hspace{.08em} #1 \hspace{.08em} #4 \hspace{.08em} #1 \hspace{.08em} #5 \hspace{.08em}}

% Used in logical sentences $[\forall m < n P(m)] \implies [P(n)]$
\newcommand{\clause}[1]{\LRSpacedBracket{#1}{}}

% Usually contains a single symbol, no need for it to be unbreaking
%\newcommand{\range}[1]{\LRSpacedBracket{#1}{\!}}
\newcommand{\range}[1]{\left[\hspace{.1em}#1\hspace{.1em}\right]}

% Set cardinality for a set (bounded by curly braces, so content may be long) or a symbol (no need for unbreaking)
\newcommand{\cardnSet}[1]{\LRSpacedPipe{#1}{\!\!}}
\newcommand{\cardnSym}[1]{\left|\hspace{.08em}#1\hspace{.08em}\right|}

% Word length, usually a single symbol, no need for breaking
\newcommand{\len}[1]{\left|\hspace{.05em}#1\hspace{.05em}\right|}

% Encoding the object(s) in an alphabet (usually 1 or 2 symbol per argument)
\newcommand{\codeOne}[1]{\LRSpacedAngle{#1}{\!}}
\newcommand{\codeTwo}[2]{\LRSpacedAngle{#1\,,\,#2}{\!}}
\newcommand{\codeThree}[3]{\LRSpacedAngle{#1\,,\,#2\,,\,#3}{\!}}
\newcommand{\codeFour}[4]{\LRSpacedAngle{#1\,,\,#2\,,\,#3\,,\,#4}{\!}}

%% Sets

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}

\newcommand{\setnot}[1]{\overline{#1}}
\newcommand{\alphabin}[1]{\setTwo{0}{1}^{#1}}

%% Functions

\newcommand{\bigO}[1]{\fofOne{\mathcal{O}}{#1}}
\newcommand{\bigOmega}[1]{\fofOne{\Omega}{#1}}
\newcommand{\power}[1]{\fofOne{\mathcal{P}}{#1}}
\newcommand{\indeg}[1]{\fofOne{\mathrm{deg}^-}{#1}}
\newcommand{\outdeg}[1]{\fofOne{\mathrm{deg}^+}{#1}}
\newcommand{\fulldeg}[1]{\fofOne{\mathrm{deg}}{#1}}
\newcommand{\Pred}[1]{\fofOne{\mathrm{P}}{#1}}
\newcommand{\Predi}[2]{\fofOne{\mathrm{P}_{#1}}{#2}}
\newcommand{\binof}[1]{\fofOne{\mathrm{bin}}{#1}}

%% Misc.

\newcommand{\absurde}{\rarrow\larrow}
\newcommand{\closure}[2]{\codeOne{#1}_{#2}}
\newcommand{\notimplies}{\;\not\!\!\!\implies}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% COMPLEXITY THEORY %%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Language classes

\newcommand{\Hard}[1]{#1\text{-difficile}}
\newcommand{\Complete}[1]{#1\text{-complet}}
\newcommand{\Co}[1]{\text{co-}#1}

\newcommand{\DTime}[1]{\fofOne{\mathsf{DTemps}}{#1}}
\newcommand{\DSpace}[1]{\fofOne{\mathsf{DEspace}}{#1}}
\newcommand{\NTime}[1]{\fofOne{\mathsf{NTemps}}{#1}}
\newcommand{\NSpace}[1]{\fofOne{\mathsf{NEspace}}{#1}}
\newcommand{\MuxClass}[2]{\fofTwo{\mathsf{MuxTapT}}{#1}{#2}}
\newcommand{\MuxStrongClass}[2]{\fofTwo{\mathsf{MuxFTapT}}{#1}{#2}}
\newcommand{\ADPDA}{\mathsf{DAuxPDA}}
\newcommand{\DAuxPDA}[2]{\fofTwo{\mathsf{DAuxPDA}}{#1}{#2}}
\newcommand{\NAuxPDA}[2]{\fofTwo{\mathsf{NAuxPDA}}{#1}{#2}}

\newcommand{\PClass}{\mathsf{P}}
\newcommand{\NPClass}{\mathsf{NP}}
\newcommand{\LClass}{\mathsf{L}}
\newcommand{\FLClass}{\mathsf{FL}}
\newcommand{\NLClass}{\mathsf{NL}}
\newcommand{\NC}[1]{\mathsf{NC}^{#1}}
\newcommand{\NCOne}{\mathsf{NC}^1}
\newcommand{\USAC}{\mathsf{SAC}}
\newcommand{\SAC}[1]{\mathsf{SAC}^{#1}}
\newcommand{\AC}[1]{\mathsf{AC}^{#1}}
\newcommand{\DCFL}{\mathsf{DCFL}}
\newcommand{\CFL}{\mathsf{CFL}}
\newcommand{\LogDCFL}{\mathsf{LOGDCFL}}
\newcommand{\LogCFL}{\mathsf{LOGCFL}}

%% Problems

\newcommand{\TreeEval}{\textnormal{\textsc{TreeEval}}}
\newcommand{\GenR}{\textnormal{\textsc{GenR}}}
\newcommand{\TSAT}{\textnormal{\textsc{3Sat}}}
\newcommand{\CVP}{\textnormal{\textsc{Cvp}}}
\newcommand{\STCONN}{\textnormal{\textsc{STConn}}}
\newcommand{\STCONNlt}{\STCONN_{\leq 2}}
\newcommand{\STCONNeq}{\STCONN_{2}}
\newcommand{\HamPath}{\textnormal{\textsc{HamPath}}}
\newcommand{\Gen}{\textnormal{\textsc{Gen}}}
\newcommand{\AGen}{\textnormal{\textsc{AGen}}}
\newcommand{\GenPath}{\textnormal{\textsc{GenPath}}}
\newcommand{\GenPathRelax}{\textnormal{\textsc{GenPathRelax}}}
\newcommand{\GenUnique}{\textnormal{\textsc{Gen}-\textsc{Unique}}}
\newcommand{\GenT}[1]{\textnormal{\textsc{Gen}-}#1}
\newcommand{\GenRangee}[1]{\textnormal{\textsc{Gen}-}#1\textsc{Rangée}}
\newcommand{\GenHT}[1]{\fofOne{\textnormal{\textsc{Gen}-\textsc{HautTem}}}{#1}}
\newcommand{\GenTT}[1]{\fofOne{\textnormal{\textsc{Gen}-\textsc{TailleTem}}}{#1}}
\newcommand{\GenRHT}[1]{\fofOne{\textnormal{\textsc{GenR}-\textsc{HautTem}}}{#1}}
\newcommand{\GenRTT}[1]{\fofOne{\textnormal{\textsc{GenR}-\textsc{TailleTem}}}{#1}}
\newcommand{\GenRTTT}[2]{\fofOne{\textnormal{\textsc{GenR}-}#1\textnormal{-\textsc{TailleTem}}}{#2}}
\newcommand{\GenPPT}{\textnormal{\textsc{Gen}-\textsc{Ppt}}}
\newcommand{\GenTRangee}[2]{\textnormal{\textsc{Gen}-}#1\textnormal{-}#2\textnormal{\textsc{Rangée}}}
\newcommand{\GenTPPT}[1]{\textnormal{\textsc{Gen}-}#1\textnormal{-\textsc{Ppt}}}
\newcommand{\GenRangeePPT}[1]{\textnormal{\textsc{Gen}-}#1\textnormal{\textsc{Rangée}-\textsc{Ppt}}}

%% Circuits

\newcommand{\CircuitFamily}[2]{\left(\,{#1}_{#2}\,\right)_{#2 \in \N}}

%% Grammar

\newcommand{\CFGgen}[2]{\xRightarrow[#2]{#1}}

%% Reductions

\newcommand{\reducBottomTop}[2]{\leq_{#1}^{#2}}
\newcommand{\reducBottom}[1]{\reducBottomTop{#1}{}}
\newcommand{\reducLog}{\reducBottom{\log}}
\newcommand{\reducP}{\reducBottom{\PClass}}
\newcommand{\reducNC}{\reducBottom{\NCOne}}
%