% Loading packages
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\hypersetup{
	colorlinks=true,
	linkcolor=blue,
	filecolor=magenta,      
	urlcolor=cyan
}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bbm}
\usepackage{stmaryrd}
\usepackage[main=french,english]{babel}
\usepackage{csquotes}
\usepackage{listings}
\usepackage{lstautogobble}
\usepackage{algorithm2e}
\usepackage{svg}
\usepackage{tikz}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{tcolorbox}
\usepackage{mdframed}
\usepackage{proof}
\usepackage{biblatex}
\usepackage{xparse}
\usepackage{cprotect}
\usepackage{titlesec}
\usepackage{xpatch}
\usepackage{enumitem}
\usepackage{amsfonts}
\usepackage{mathtools}

\usepackage{geometry}

\usepackage{csquotes}
\usepackage[lighttt]{lmodern}
\usetikzlibrary{shapes.geometric,positioning}

% Macros caractères globales
\newcommand{\pgrph}{\P}
\newcommand{\hsep}{\vspace{.2cm}\centerline{\rule{0.8\linewidth}{.05pt}}\vspace{.4cm}}
\renewcommand{\P}{\mathbb{P}}
\newcommand{\E}{\mathbb{E}}
\newcommand{\1}{\scalebox{1.2}{$\mathbbm{1}$}}
\newcommand{\floor}[1]{\left\lfloor#1\right\rfloor}
\newcommand{\littleO}{o}
\newcommand{\bigO}{\mathcal{O}}
\newcommand{\longdash}{\:\textrm{---}\:}
\newcommand\hole{\left[\raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}\right]}
\newcommand\bracket[1]{\!\left[#1\right]}
\newcommand{\ssi}{\quad\text{\underline{ssi}}\quad}
\newcommand\eng[1]{\textit{\foreignlanguage{english}{#1}}}
\newcommand\spacebar{\;|\;}
\def\nDownarrow{\not\mspace{1mu}\Downarrow}
\let\pprec\preccurlyeq

\DeclareUnicodeCharacter{03BB}{$\lambda$}
\DeclareUnicodeCharacter{03B1}{$\alpha$}
\DeclareUnicodeCharacter{03C0}{$\pi$}

% Création des environnement globaux
\newtheorem{theorem}{Théorème}
\newtheorem{definition}{Definition}
\newtheorem{property}{Propriété}

\newcounter{rule}
\addto\extrasfrench{%
	\renewcommand{\figureautorefname}{\textsc{Figure}}
	\renewcommand{\sectionautorefname}{Section}
	\renewcommand{\subsectionautorefname}{Sous-section}
	\renewcommand{\appendixautorefname}{Annexe}
	\renewcommand{\theoremautorefname}{Théorème}
	\providecommand\propertyautorefname{Propriété}
	\providecommand\ruleautorefname{règle}
}

% Commandes logiques globales
\newcommand{\ifnullthenelse}[3]{
	\ifnum\value{#1}=0
	#2
	\else
	#3
	\fi
}

%%% Commande \newtag permettant de changer le label d'une equation
\makeatletter
\newcommand\newtag[2]{#1\def\@currentlabel{#1}\label{#2}}
\makeatother


% Macros caractères spécifiques au document
\newcommand{\methprec}[1]{\prec\mkern-8mu\left[\fj{#1}\right]}
\DeclareMathOperator{\varnull}{varnull}
\DeclareMathOperator{\nextop}{next}
\DeclareMathOperator{\new}{\text{\textbf{new}}}
\DeclareMathOperator{\CT}{CT}
\DeclareRobustCommand{\leftsarrow}{\text{\reflectbox{$\;\rightarrow^*$}}}
\newcommand\subclass{\mathrel{<:}}
\newcommand\superclass{\mathrel{:>}}
\newcommand\OKin{\text{\textnormal{\textsc{ OK in }}}}

% Création des environnements spécifiques au document
\newcounter{hyp}

\makeatletter
\newif\if@mathitemize
\newif\if@closemathitem
\let\orig@item=\item
\newenvironment{hypenumerate}{\enumerate}{\endenumerate}
\newcommand{\hypitem}{\if@closemathitem$\fi\orig@item\if@mathitemize\@closemathitemtrue$\fi}
\newenvironment{hyps}{\let\item\hypitem \@mathitemizetrue\hypenumerate\@closemathitemfalse}{$\endhypenumerate}
\makeatother


%%% Subparaghaphs box
\newtcbox{\subparaghaphbox}{nobeforeafter,tcbox raise base, arc=9pt, outer arc=9pt, boxsep=2pt,left=2pt,right=2pt,top=2pt,bottom=2pt,boxrule=1pt,colback=white!85!orange}
\newcommand{\subparaghaphboxedcontent}[1]{\subparaghaphbox{#1}\newline}
%\titleclass{\mathcases}{straight}[\subparagraph]
\titleformat{\subparagraph}[runin]{\normalfont\normalsize\bfseries}{}{0em}{\subparaghaphboxedcontent}
\titlespacing*{\subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0.5em}

%%% Blocs colorés pour le code FeatherweightJava
\newtcbox{\fjmaincodebox}{nobeforeafter,tcbox raise base, arc=0pt, outer arc=0pt, boxsep=0pt,left=2pt,right=2pt,top=2pt,bottom=2pt,boxrule=0pt,colback=white!85!black}
\newtcbox{\fjind}{nobeforeafter,tcbox raise base, rounded corners=all, boxsep=0pt,left=1pt,right=1pt,top=1pt,bottom=1pt,boxrule=0pt,colback=white!52!orange}
\newenvironment{fjlisting}[1][]
{
	\begin{tcolorbox}[left=5pt,right=2pt,top=5pt,bottom=5pt,boxrule=1pt,rounded corners=all,colback=white!96!black,#1]
		\ttfamily
	}{
	\end{tcolorbox}
}

% Langage Featherweight Java
\makeatletter
\newcommand*\idstyle{%
	\expandafter\id@style\the\lst@token\relax
}
\def\id@style#1#2\relax{%
	\ifcat#1\relax\else
	\ifnum`#1=\lccode`#1%
	\ttfamily
	\fi
	\fi
}
\makeatother
\lstdefinelanguage{FeatherweightJava}{
	keywords = {new, this, true, false},
	basicstyle=\ttfamily,
	identifierstyle=\idstyle
}

%% Commande 4
\NewDocumentEnvironment{textenv}{b}{\text{\textnormal{#1}}}{}
%\lstMakeShortInline[language=FeatherweightJava]|
\newcommand{\fj}[1]{\begin{textenv}\lstinline[language=FeatherweightJava,mathescape=true]~#1~\end{textenv}}

% Définition des macros pour l'écriture des trucs Featherweight Java
\newcommand\fjattr{\GenericWarning{$\backslash$ fjattr doit être utilisé dans une fjclass}}
\newcounter{fjargcount}
\newcommand{\fjparamattributes}[2][Object]{
	\null\qquad #1 #2;\newline
}
\newcommand{\printcomma}{,}
\newcommand{\fjparamconstparameters}[2][Object]{
	\ifnullthenelse{fjargcount}{}{,$\text{ }$} \text{#1} \;\text{#2}
	\stepcounter{fjargcount}
}
\newcommand{\fjparamconstassign}[2][Object]{
	\null\qquad\qquad \textbf{this}.#2 = #2;\newline
}
\newcommand{\fjmethod}[4]{
	\null\qquad #1 #2(#3)\{\newline
	\null\qquad\qquad \textbf{return} \lstinline[language=FeatherweightJava]{#4};\newline
	\null\qquad\}\newline
}

\newcommand{\fjmain}[1]{
	\noindent\fjmaincodebox{\lstinline[language=Java]{#1}}
}

% Premier argument: Nom de la classe
% Second argument: \fjattr{x}[Object] \fjattr{attr}[A]
% Troisième argument \fjmethod{C}{metname}{Object w, B par}{((D)obj).apply(par)} plusieurs fois
% Argument optionnel: la classe que l'on extend
\newcommand{\fjclass}[4][Object]{%
	\noindent \textbf{class} #2 \textbf{extends} #1 \{\newline
	% Attributs
	\let\fjattr\fjparamattributes
	#3
	% Constructeur
	\let\fjattr\fjparamconstparameters
	\setcounter{fjargcount}{0}
	\null\qquad #2(\ifx&#3&\else $#3$\fi) \{\newline
	\null\qquad\qquad \textbf{super}();\newline
	\let\fjattr\fjparamconstassign%
	#3
	\null\qquad\}\\
	% Méthodes
	#4
	\}
}

\addbibresource{Bilibibio.bib}
