%\RequirePackage{atbegshi}
\documentclass[french]{beamer}
\usepackage{etex}

\usepackage[beamer,utf8x,fourier]{preambuleTrm}
%\usepackage[french,vlined,boxed]{algorithm2e}
\usepackage{bookmark,multido}
%\usepackage{xlop}


\usepackage{tikz}
\usetikzlibrary{automata,fit,trees,matrix,arrows,decorations.pathmorphing,shapes,arrows,chains,positioning,intersections,backgrounds,calc,through,mindmap}
\newcommand{\myunit}{1.1cm}
\usepackage{tkz-graph}
\usepackage{circuitikz}


\usepackage{caption}
\captionsetup{labelformat=empty,font=footnotesize}


\usepackage{media9}

%\usepackage{multimedia}
% \usepackage{cclicenses}
% \usepackage{cclicence}
\setbeamertemplate{theorems}[numbered]




\usepackage{algo}

\renewcommand{\algocommentfont}{\small\ttfamily\itshape}

\newcommand\nor{\downarrow}
\newcommand\nand{\uparrow}
\newcommand\xor{\oplus}

\newcommand\foncpart{\rightarrow\!\!\!\!\!\!\shortmid}
\newcommand\fonctot{\rightarrow}
\newcommand\injpart{\rightarrowtail\!\!\!\!\!\!\!\shortmid}
\newcommand\injtot{\rightarrowtail}
\newcommand\surjpart{\twoheadrightarrow\!\!\!\!\!\!\!\shortmid}
\newcommand\surjtot{\twoheadrightarrow}
\newcommand\bijpart{\rightarrowtail\!\!\!\!\!\!\!\shortmid\!\!\!\!\twoheadrightarrow}
\newcommand\bijtot{\rightarrowtail\!\!\!\!\!\!\!\!\!\twoheadrightarrow}


\newtheorem{exercice}{Exercice}


\setlength{\columnseprule}{0pt}

%\setlength{\parskip}{0pt}

\graphicspath{{/home/moi/IUT/PolyINFO1}{/home/moi/IUT/INFO2/Images/}{/home/moi/IUT/INFO2/Images/FaceDB/}{/home/moi/Lycee/TDmaple/2006_7/}{/home/moi/Figures/Arbres_Graphes/}{/home/moi/Figures/FigSTI/}{/home/moi/Figures/FigMaple/}{/home/moi/Photos/Maths/}{/home/moi/Photos/Tehessin/}{/home/moi/Figures/FigSTI/}{/home/moi/Figures/FigSeconde/}{/home/moi/Lycee/Informatique/XCAS/2008_9/}{/home/moi/Lycee/TDmaple/2008_9/}{/home/moi/IUT/Thierry/Conversions/}{/home/moi/Photos/informathix/}{/home/moi/Lycee/Informatique/PafAlgo/}}




\newcommand\caml{\lstset{numbers=none,language=Caml,xleftmargin=10pt,%
keywordstyle =\small\color{orange!40}\usefont{OT1}{cmtt}{b}{n},basicstyle=\small\ttfamily\color{white},commentstyle=\normalfont\scriptsize\slshape,breaklines=true,backgroundcolor=\color{black!90!red},frame=trBL,framerule=1pt,framesep=4pt,rulesep=1pt,showstringspaces=false,stringstyle=\slshape,captionpos=b}
}



\newcommand\haskell{\lstset{numbers=none, escapeinside={(*@}{@*)},language=haskell,xleftmargin=10pt,%
keywordstyle =\footnotesize\color{blue!40}\usefont{OT1}{cmtt}{b}{n},basicstyle=\footnotesize\ttfamily\color{white},commentstyle=\normalfont\scriptsize\slshape,breaklines=true,backgroundcolor=\color{black!90!blue},frame=trBL,framerule=1pt,framesep=4pt,rulesep=1pt,showstringspaces=false,stringstyle=\slshape,captionpos=b}
}


\newcommand\python{\lstset{numbers=none,language=sage,xleftmargin=10pt,%
keywordstyle =\color{blue!40}\usefont{OT1}{cmtt}{b}{n},basicstyle=\ttfamily\color{white},commentstyle=\normalfont\scriptsize\slshape,breaklines=true,backgroundcolor=\color{black!90!blue},frame=trBL,framerule=1pt,framesep=4pt,rulesep=1pt,showstringspaces=false,stringstyle=\slshape,captionpos=b}
}




\newcommand\lat{\lstset{numbers=none,language=[LaTeX]TeX,xleftmargin=10pt,%
keywordstyle =\color{blue!40}\usefont{OT1}{cmtt}{b}{n},basicstyle=\ttfamily\color{white},commentstyle=\normalfont\scriptsize\slshape,breaklines=true,backgroundcolor=\color{black!90!blue},frame=trBL,framerule=1pt,framesep=4pt,rulesep=1pt,showstringspaces=false,stringstyle=\slshape,captionpos=b}
}





\setcounter{tocdepth}{1} %\setcounter{page}{0}


\renewcommand\FancyVerbFormatLine[1]{\colorbox{green}{#1}}


\mode<presentation>
{
  \usetheme[secheader]{Madrid}
  % or ...Warsaw

  \setbeamercovered{highly dynamic}
  % or whatever (possibly just delete it)
}
\usepackage{elephantbird}

\newcommand{\triangleup}{\Delta}

\begin{document}


\title[] % (optional, use only with long paper titles)
{Structures algébriques / Classes en Haskell}

\subtitle{INFO1 - Semaine 48}

\author[] % (optional, use only with lots of authors)
{Guillaume CONNAN }
% - Give the names in the same order as the appear in the paper.
% - Use the inst{?} command only if the authors have different
%   affiliation.

\institute{\textsc{IUT} de Nantes - Dpt d'informatique }% (optional, but mostly needed)

\logo{\includegraphics[scale=0.15]{logo_iut}}

%\logo{\includegraphics[scale=0.15]{big_connan}}

\date[] % (optional, should be abbreviation of conference name)
{Dernière mise à jour: \today{} à \now}
% - Either use conference name or its abbreviation.
% - Not really informative to the audience, more for people (including
%   yourself) who are reading the slides online

\subject{ }


\beamerdefaultoverlayspecification{<+->}

% \AtBeginSubsubsection[]
% {
%   \begin{frame}<beamer>
%     \frametitle{Sommaire}
%  {\scriptsize
% \begin{multicols}{2}
%     \tableofcontents[currentsection,currentsubsection]
%        \end{multicols}
% }

%   \end{frame}
% }




% \AtBeginSubsection[]
% {\scriptsize
%   \begin{frame}<beamer>
%     \frametitle{Sommaire}
%  {\tiny
% \begin{multicols}{2}
%     \tableofcontents[currentsection,currentsubsection]
%        \end{multicols}
% }

%   \end{frame}
% }





\AtBeginSection[]
{
  \begin{frame}<beamer>
    \frametitle{Sommaire}
 {\scriptsize
\begin{multicols}{2}
    \tableofcontents[currentsection]
       \end{multicols}
}

  \end{frame}
}


% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command: 

\beamerdefaultoverlayspecification{<+->}




\newcommand{\TR}{\mathcal{T}}


\begin{frame}
  \titlepage
\end{frame}

\begin{frame}
 \frametitle{Sommaire}
{\scriptsize
\begin{multicols}{2} 
 \tableofcontents
\end{multicols}
}

 
 \end{frame}


\haskell


\section{Calcul modulaire sans arithmétique...}



\begin{frame}[fragile]
  \begin{lstlisting}
Prelude> data Romain = O | I | II | III | IV | V deriving (Enum, Bounded, Eq, Show) 
  \end{lstlisting}

\pause

  \begin{lstlisting}
Prelude> minBound :: Romain
O
  \end{lstlisting}


\pause


\begin{lstlisting}
Prelude> maxBound :: Romain
V
\end{lstlisting}


\pause


\begin{lstlisting}
Prelude> minBound :: Int
-9223372036854775808
Prelude> maxBound :: Int
9223372036854775807
\end{lstlisting}

\end{frame}



\begin{frame}[fragile]
  \begin{lstlisting}
Prelude> succ II
III
  \end{lstlisting}

\pause

\begin{lstlisting}
Prelude> pred V
IV
\end{lstlisting}


\pause


\begin{lstlisting}
Prelude> succ V
*** Exception: succ{Romain}: tried to take `succ' of last tag in enumeration
\end{lstlisting}



\pause

\begin{lstlisting}
Prelude> [II .. V]
[II,III,IV,V]
\end{lstlisting}
\end{frame}



\begin{frame}[fragile]


  \begin{lstlisting}
Prelude> :t fromEnum
fromEnum :: Enum a => a -> Int
  \end{lstlisting}

\pause

\begin{lstlisting}
Prelude> fromEnum II
2
\end{lstlisting}


\pause

\begin{lstlisting}
Prelude> toEnum 5 :: Romain
V
\end{lstlisting}

\end{frame}


\begin{frame}[fragile]
  \begin{lstlisting}
data ClasseMod t = (Eq t, Show t, Enum t, Bounded t) => Zn t 
  \end{lstlisting}


\pause


\begin{lstlisting}
data LesZ5 = O5 | I5 | II5 | III5 | IV5 deriving (Eq,Show, Bounded, Enum)

type Z5 = ClasseMod LesZ5
\end{lstlisting}

\pause

\begin{lstlisting}
instance (Show t) => Show (ClasseMod t) where
  show (Zn x) = show x
\end{lstlisting}


\end{frame}





\begin{frame}[fragile]

  \begin{lstlisting}
*CalMod> Zn II5
II5
  \end{lstlisting}


\end{frame}



\begin{frame}[fragile]

  \begin{lstlisting}
succZn :: (ClasseMod t) -> (ClasseMod t) 
succZn (Zn x)        = if (x == maxBound) then (Zn minBound) else (Zn (succ x))
  \end{lstlisting}


\pause

\begin{lstlisting}
*CalMod> succZn (Zn III5)
IV5
\end{lstlisting}


\pause

\begin{lstlisting}
*CalMod> succZn (Zn IV5)
O5
\end{lstlisting}


\pause 


\verb+predZn+ ??

\end{frame}






\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Enum (ClasseMod t) where
  succ = succZn
  \end{lstlisting}


\pause


\begin{lstlisting}
*CalMod> succ (Zn III5)
IV5
\end{lstlisting}

\end{frame}








\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Enum (ClasseMod t) where
  succ = succZn
  pred = predZn
  \end{lstlisting}


\pause



\begin{lstlisting}
*CalMod> pred (Zn III5)
II5
\end{lstlisting}


\end{frame}







\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Enum (ClasseMod t) where
  succ = succZn
  pred = predZn
  fromEnum (Zn x) = fromEnum x
  \end{lstlisting}




\pause


\begin{lstlisting}
*CalMod> fromEnum IV5
4
\end{lstlisting}


\end{frame}






\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Enum (ClasseMod t) where
  succ = succZn
  pred = predZn
  fromEnum (Zn x) = fromEnum x
  toEnum n = Zn (toEnum n)
  \end{lstlisting}


\pause

\begin{lstlisting}
*CalMod> toEnum 4 :: Z5
IV5
\end{lstlisting}


\end{frame}













\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t) => Eq (ClasseMod t) where
  (Zn x) == (Zn y) = x == y
  \end{lstlisting}

\pause


\begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Bounded (ClasseMod t) where
  maxBound = Zn (maxBound)
  minBound = Zn (minBound)
\end{lstlisting}

\end{frame}


\begin{frame}[fragile]

  \begin{lstlisting}
plusZn  x y = 
  if (fromEnum x == 0) then y
  else
    succ (plusZn (pred x) y)
  \end{lstlisting}


\pause


Multiplication ??

\end{frame}



\begin{frame}[fragile]

  \begin{lstlisting}
foisZn x y =
  if (fromEnum x == 0) then (toEnum 0)
  else
    if (fromEnum x == 1) then y
    else plusZn y (foisZn (pred x) y) 
  \end{lstlisting}
  
\end{frame}





\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Num (ClasseMod t) where
  \end{lstlisting}

\end{frame}








\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Num (ClasseMod t) where
  (+) = plusZn
  \end{lstlisting}

\end{frame}













\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Num (ClasseMod t) where
  (+) = plusZn
  (*) = foisZn
  \end{lstlisting}

\end{frame}





















\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Num (ClasseMod t) where
  (+) = plusZn
  (*) = foisZn
  fromInteger  = classeOfInt 
  \end{lstlisting}

\end{frame}












\begin{frame}[fragile]

  \begin{lstlisting}
instance (Eq t, Show t, Enum t, Bounded t) => Num (ClasseMod t) where
  (+) = plusZn
  (*) = foisZn
  fromInteger  = classeOfInt 
  negate x =  toEnum (- (fromEnum x) + (fromEnum (maxBound :: ClasseMod t)) + 1)
  \end{lstlisting}

\end{frame}




\begin{frame}[fragile]

  \begin{lstlisting}
*CalMod> 2 :: Z5
II5
  \end{lstlisting}

\end{frame}




\begin{frame}[fragile]

  \begin{lstlisting}
*CalMod> 2 :: Z5
II5
*CalMod> 17 :: Z5
II5
  \end{lstlisting}

\end{frame}





\begin{frame}[fragile]

  \begin{lstlisting}
*CalMod> 2 :: Z5
II5
*CalMod> 17 :: Z5
II5
*CalMod> (-3) :: Z5
II5
  \end{lstlisting}

\end{frame}






\begin{frame}[fragile]

  \begin{lstlisting}
*CalMod> 2 :: Z5
II5
*CalMod> 17 :: Z5
II5
*CalMod> (-3) :: Z5
II5
*CalMod> (-3) + 9 :: Z5
I5
  \end{lstlisting}

\end{frame}




























\begin{frame}[fragile]

  \begin{lstlisting}
*CalMod> 2 :: Z5
II5
*CalMod> 17 :: Z5
II5
*CalMod> (-3) :: Z5
II5
*CalMod> (-3) + 9 :: Z5
I5
*CalMod> 3 * 7 :: Z5
I5
  \end{lstlisting}

\end{frame}





\begin{frame}[fragile]

  \begin{lstlisting}
*CalMod> 2 :: Z5
II5
*CalMod> 17 :: Z5
II5
*CalMod> (-3) :: Z5
II5
*CalMod> (-3) + 9 :: Z5
I5
*CalMod> 3 * 7 :: Z5
I5
*CalMod> 301 * 7157 :: Z5
II5
  \end{lstlisting}

\end{frame}



\section{Rationnels}


\end{document}
%%% Local Variables: 
%%% TeX-master: t
%%% End: 
