commit initial

Cette révision appartient à :
Yann Salmon
2018-02-21 19:12:43 +01:00
révision 13480dc69d
16 fichiers modifiés avec 936 ajouts et 0 suppressions

0
latex/commun.bib Fichier normal
Voir le fichier

33
latex/conversion.py Fichier normal
Voir le fichier

@@ -0,0 +1,33 @@
def code(s) :
try :
debut = s.index(r"\begin{tabbing}")
fin = s.index(r"\end{tabbing}")
pos_let = s.index("let", debut)
if s[pos_let+3:].startswith(" rec") :
pos_let = pos_let + 4
pos_nom = s.index(" ", pos_let) + 1
fin_nom = s.index(" ", pos_nom)
nom = s[pos_nom:fin_nom]
repl = r"\lstinputcaml[linerange="+nom+"-"+nom+"_fin]{ccp2004.ml}\n"
news = s[:debut] + repl + s[fin + len(r"\end{tabbing}"):]
return code(news)
except ValueError :
return s
def caml(s, start=0) :
try :
pos_let = s.index("\nlet", start)
fin = s.index(r";;", pos_let)
print(s[pos_let:fin+3])
if s[pos_let+4:].startswith(" rec") :
delta = 5
else :
delta = 0
pos_nom = s.index(" ", pos_let + delta) + 1
fin_nom = s.index(" ", pos_nom)
nom = s[pos_nom:fin_nom]
print(nom)
news = s[:pos_let] + "(*** " + nom + " ***)" + s[pos_let:fin+3] + "(*** " + nom + "_fin ***)\n" + s[fin+3:]
return caml(news, fin + 3 + len("(*** " + nom + " ***)")+ len("(*** " + nom + "_fin ***)\n"))
except ValueError :
return s

3
latex/inputDS.tex Fichier normal
Voir le fichier

@@ -0,0 +1,3 @@
\subimport{./}{inputTD}
\endinput

81
latex/inputTD.tex Fichier normal
Voir le fichier

@@ -0,0 +1,81 @@
\makeatletter
\@ifundefined{stylecentrale}
{\def\resetlevel{section}}
{%
\renewcommand\thesection{\Roman{section}}%
\renewcommand\thesubsection{\thesection.\Alph{subsection}}%
\def\resetlevel{subsection}
}
\theoremstyle{plain}
\theoremheaderfont{\bfseries}
\theorembodyfont{\upshape}
\theoremseparator{. }
\theoremsymbol{}
\newtheorem*{important}{Important}
\newtheorem*{rappel}{Rappel}
\usepackage{xfrac}
\usepackage{xparse}
\usepackage{comment}
\newif\ifcorrige
\def\corr{\filigrane{\Huge CORRIG\'E --- CORRIG\'E}\global\corrigetrue}
\newif\ifcorrigeseul
\def\corrseul{\filigrane{\Huge CORRIG\'E --- CORRIG\'E}\global\corrigeseultrue}
\usepackage{xstring}
\IfEndWith{\jobname}{\detokenize{-ENONCE}}{\let\corr\relax\let\corrseul\relax}{}
\IfEndWith{\jobname}{\detokenize{-PROF}}{\corr\let\corr\relax\let\corrseul\relax}{}
\IfEndWith{\jobname}{\detokenize{-CORRIGE}}{\corrseul\let\corr\relax\let\corrseul\relax}{}
\def\pasenonce{
\excludecomment{question}
\excludecomment{enonce}
\excludecomment{qcmrep}
\excludecomment{qcm}
}
\def\avecenonce{\newenvironment{enonce}{}{}
\newtheorem{question}{Question}[\resetlevel]
\def\skipcorrige{}
\newtheorem{qcm}{QCM}
%
\NewDocumentEnvironment{qcmrep}{o}
{\IfValueT{##1}{\begingroup\setlength\columnseprule{0pt}\begin{multicols}{##1}}\begin{enumerate}\renewcommand\theenumi{\Alph{enumi}}}{\end{enumerate}\IfValueT{##1}{\end{multicols}\endgroup}}}
\AtBeginDocument{%
\ifcorrige
\immediate\typeout{Mode professeur}
\makeatletter\IfStrEq{\@subtitle}{}{}{\subtitle{Corrigé}}\makeatother
\newenvironment{corrige}{\begin{mdframed}[backgroundcolor=gray!20, skipbelow=1ex]}{\end{mdframed}}
\newenvironment{comcorrige}{\begin{mdframed}[backgroundcolor=gray!20, skipbelow=1ex]}{\end{mdframed}}
\newenvironment{qcmcorr}{\begin{mdframed}[backgroundcolor=gray!20, skipbelow=1ex]}{\end{mdframed}}
\avecenonce
\else\ifcorrigeseul
\immediate\typeout{Mode corrige}
\makeatletter\IfStrEq{\@subtitle}{}{}{\subtitle{Corrigé}}\makeatother
\pasenonce
\newtheorem{corrige}{Question}[\resetlevel]
\newtheorem{qcmcorr}{QCM}
\newenvironment{comcorrige}{}{}
\def\skipcorrige{\stepcounter{corrige}}
\else
\immediate\typeout{Mode enonce}
\excludecomment{corrige}
\excludecomment{comcorrige}
\excludecomment{qcmcorr}
\avecenonce
\fi\fi
}
\DeclareInstance{xfrac}{cinqdemi}{text}{scale-factor=1, h-scale=1.25, slash-left-kern=-2.5pt, slash-right-kern=-2.25pt}
\def\cinqdemi{\sfrac[cinqdemi]{5}{2}}
\endinput

47
latex/logique.py Fichier normal
Voir le fichier

@@ -0,0 +1,47 @@
import itertools
def dA(s) :
return s[0] and s[1] and not s[2]
def dB(s) :
return not s[2]
def dC(s) :
return (s[1] or not s[0]) and not (s[1] and not s[0])
def dmA(s) :
return s[0] == dA(s)
def dmB(s) :
return s[1] == dB(s)
def dmC(s) :
return s[2] == dC(s)
def OK(s) :
return dmA(s) and dmB(s) and dmC(s)
def table(nvar, lf) :
produit = list(itertools.product([False, True], repeat=nvar))
table = []
for s in produit :
ligne = {"s" : s}
for f in lf :
ligne[f.__name__] = f(s)
table.append(ligne)
return table
def table_to_latex(table, vars, lf) :
fb = lambda b : r"\V" if b else r"\F"
#keys = [x for x in sorted(list(table[0].keys())) if x!="s"]
keys = [f.__name__ for f in lf]
print(r"\begin{array}{"+ "|".join(["c"] * len(vars)) + "||" + "|".join(["c"] * len(keys)) + "}")
print("&".join(vars + [x for x in keys])+r"\\")
print(r"\hline")
for l in table :
print("&".join([fb(x) for x in l["s"]]+[fb(l[k]) for k in keys]),r"\\", sep="")
print(r"\end{array}")
def table_latex(vars, lf) :
t = table(len(vars), lf)
table_to_latex(t, vars, lf)

21
latex/maketd.py Fichier exécutable
Voir le fichier

@@ -0,0 +1,21 @@
#!/usr/bin/env python3
import subprocess
import sys
import os
def compiler(nf, suff) :
basedir = os.path.dirname(nf)
builddir = os.path.join(basedir, "_build")
basejobname = os.path.splitext(os.path.basename(nf))[0]
subprocess.call(["latexmk", "-pdflua", "-shell-escape", "-bibtex-cond", "-cd", "-interaction=batchmode", "-dvi-", "-jobname="+basejobname+suff, "-outdir=" + builddir, "-latexoption=\"--output-directory="+builddir+"\"", nf])
os.rename(os.path.join(builddir, basejobname+suff+".pdf"), os.path.join(basedir, basejobname+suff+".pdf"))
def clean(nf, suff) :
subprocess.call(["latexmk", "-cd", "-c", "-jobname="+os.path.splitext(os.path.basename(nf))[0]+suff, nf])
for suff in ["-ENONCE", "-PROF", "-CORRIGE"] :
compiler(sys.argv[1], suff)

102
latex/paquets.tex Fichier normal
Voir le fichier

@@ -0,0 +1,102 @@
\makeatletter
\usepackage{ifluatex}
\ifluatex
\usepackage{shellesc}
\fi
\usepackage{silence}
\WarningsOff[hyperref]
\usepackage{xcolor}%
\usepackage{colortbl}
\usepackage{graphicx}%
\usepackage{fontspec}
\usepackage{babel}
\usepackage{pdfpages}
\usepackage{textcomp}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont[Renderer=ICU, SlantedFont=Gentium Basic, SlantedFeatures={FakeSlant},SmallCapsFont=Gentium Plus, SmallCapsFeatures={Letters=SmallCaps}]{Gentium Basic}
\setmonofont[FakeStretch=.7,BoldFont=Source Code Pro Semibold]{Source Code Pro}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}
\setmathfont{texgyrepagella-math.otf}[Scale = MatchLowercase]
\setmathfont{Asana-Math.otf}[range={\varnothing}, Scale = MatchLowercase]
\setmathfont{texgyrepagella-math.otf}[range={\int}, Scale = MatchLowercase] %% https://tex.stackexchange.com/a/386937/103608
\ifluatex
\relax
\else
\Udelcodenum`.=1073741824 %% WTF https://tex.stackexchange.com/a/386937/103608
\fi
\AtBeginDocument{\let\setminus\smallsetminus}
\setmathfont[range=scr]{xits-math.otf}
\setmathfontface\mathcal{MnSymbol}
\setmathfontface\mathit{texgyrepagella-italic.otf}[Scale = MatchLowercase]
\setmathfontface\mathsf{texgyredejavu-math.otf}[Scale = MatchLowercase]
\def\tmit#1{\text{\fontspec{texgyrepagella-italic.otf}[Scale = MatchLowercase] #1}}
\let\mtit\tmit
\let\textdef\textit
\@ifundefined{ys@beamer}{
\addtokomafont{disposition}{\rmfamily}
\setkomafont{descriptionlabel}{\bfseries}
}{}
\usepackage[babel]{csquotes}
\usepackage{microtype}
\usepackage[hang, centerlast]{subfigure}
\usepackage{epsfig}
\subimport{./}{unicode}
\subimport{./}{ystikz}
\subimport{./}{ystheorem}
\usepackage[backend=biber, style=alphabetic]{biblatex}
\addbibresource{commun.bib}
\subimport{./}{yslistings}
\usepackage{mdframed}
\definecolor{shadecolor}{gray}{.9}
\usepackage{tikz}
\usepackage[printwatermark]{xwatermark}
\newsavebox\mybox
\def\filigrane#1{%
% \savebox\mybox{\tikz[color=black,opacity=0.15]\node{#1};}
% \newwatermark*[allpages,angle=45,scale=3,xpos=0,ypos=0]{\usebox\mybox}
}
\usepackage{multicol}
\newenvironment{enumq}{\begin{enumerate}\renewcommand*{\theenumi}{\alph{enumi}}\@ifundefined{thequestion}{\renewcommand*\p@enumi{\thecorrige.}}{\renewcommand*\p@enumi{\thequestion.}}}{\end{enumerate}}
\newenvironment{multiq}[1]{\begin{multicols}{#1}\begin{enumq}}{\end{enumq}\end{multicols}}
\usepackage[nolinks]{qrcode}
\def\marginqrcode#1{\marginparsep=2pt\marginparwidth=.9cm\marginpar{\qrcode[height=.9cm,level=L]{#1}}}
\@ifundefined{ys@beamer}{
\usepackage{hyperref}
\hypersetup{hidelinks, hyperfootnotes=false, hyperindex=false, implicit=false, bookmarks=false, pdfpagelabels=false, breaklinks=true, pdfencoding=unicode}
}{}
\usepackage[os=win]{menukeys}
\renewmenumacro{\keys}{shadowedangularkeys}
\subimport{./}{yssymbols}
\makeatother
\endinput

22
latex/unicode.tex Fichier normal
Voir le fichier

@@ -0,0 +1,22 @@
\usepackage{eurosym}
\usepackage{newunicodechar}
\newunicodechar{}{\geneuro{}}
\newunicodechar{}{'}
\newunicodechar{α}{\alpha}
\newunicodechar{Δ}{\Delta}
\newunicodechar{}{\ensuremath{\leqslant}}
\newunicodechar{}{\ensuremath{\geqslant}}
\newunicodechar{«}{\guillemotleft{}}
\newunicodechar{»}{\guillemotright{}}
\newunicodechar{œ}{\oe }
\newunicodechar{}{-}
\newunicodechar{}{-}
\newunicodechar{}{\ensuremath{\leftrightarrow}}
\newunicodechar{©}{\textcopyright}
\newunicodechar{}{\dots}
\newunicodechar{×}{\ensuremath{\times}}
\newunicodechar{·}{\ensuremath{\cdot}}
\newunicodechar{φ}{\ensuremath{\phi}}
\newunicodechar{}{\ensuremath{\in}}
\newunicodechar{}{\ensuremath{\neq}}
\endinput

110
latex/ysbeamer.tex Fichier normal
Voir le fichier

@@ -0,0 +1,110 @@
\makeatletter
\let\ys@beamer\
\makeatother
\subimport{./}{paquets}
\def\seizeneuf{\usepackage[orientation=landscape,size=custom,width=16,height=9,scale=0.42]{beamerposter}}
\def\seizedix{\usepackage[orientation=landscape,size=custom,width=16,height=10,scale=0.423]{beamerposter}}
%\seizedix
\makeatletter
\@ifundefined{inserttotalframenumbernew}{
\gdef\inserttotalframenumbernew{1}
}{}
\global\let\inserttotalframenumber\inserttotalframenumbernew
\makeatother
\providecommand\thispdfpagelabel[1]{}
\usetheme{Warsaw}
%\useinnertheme[shadow]{rounded}
\usecolortheme{beaver}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{(\insertframenumber/\inserttotalframenumbernew)\hfill(\insertframenumber/\inserttotalframenumbernew)}
\usefonttheme{serif}
\usefonttheme{professionalfonts}
\setcounter{framenumber}{-1}
\newdimen\monwd
\newdimen\monht
\newdimen\mondp
\def\maxdeuxt<#1>#2<#3>#4{%
\setbox0=\hbox{#2}%
\monwd=\wd0%
\monht=\ht0%
\mondp=\dp0%
\setbox0=\hbox{#4}%
\ifdim\wd0>\monwd\monwd=\wd0\fi
\ifdim\ht0>\monht\monht=\ht0\fi
\ifdim\dp0>\mondp\mondp=\dp0\fi
\setbox0=\hbox to\monwd{\hss\only<#1>{#2}\only<#3>{#4}\hss}%
\ht0=\monht\dp0=\mondp
\box0{}
}
\def\maxtroist<#1>#2<#3>#4<#5>#6{%
\maxdeuxt<#1>{#2}<#3, #5>{\maxdeuxt<#3>{#4}<#5>{#6}}
}
\def\maxdeuxm<#1>#2<#3>#4{%
\setbox0=\hbox{\(#2\)}%
\monwd=\wd0%
\monht=\ht0%
\mondp=\dp0%
\setbox0=\hbox{\(#4\)}%
\ifdim\wd0>\monwd\monwd=\wd0\fi
\ifdim\ht0>\monht\monht=\ht0\fi
\ifdim\dp0>\mondp\mondp=\dp0\fi
\setbox0=\hbox to\monwd{\hss\only<#1>{\(#2\)}\only<#3>{\(#4\)}\hss}%
\ht0=\monht\dp0=\mondp
\box0{}
}
\def\maxtroism<#1>#2<#3>#4<#5>#6{%
\maxdeuxm<#1>{#2}<#3, #5>{\maxdeuxm<#3>{#4}<#5>{#6}}
}
\def\maxdeux{\ifmmode\let\next\maxdeuxm\else\let\next\maxdeuxt\fi\next}
\def\maxtrois{\ifmmode\let\next\maxtroism\else\let\next\maxtroist\fi\next}
\long\def\maxdeuxv<#1>#2<#3>#4{%
\setbox0=\vbox{#2}%
\monwd=\wd0%
\monht=\ht0%
\mondp=\dp0%
\setbox0=\vbox{#4}%
\ifdim\wd0>\monwd\monwd=\wd0\fi
\ifdim\ht0>\monht\monht=\ht0\fi
\ifdim\dp0>\mondp\mondp=\dp0\fi
\setbox0=\vbox to\monht{\only<#1>{#2}\only<#3>{#4}}%
\wd0=\monwd \dp0=\mondp
\box0{}
}
%\def\maxdeux<#1>#2<#3>#4{\alt<#1>{#2}{#4}<#3>}
%\def\maxtrois<#1>#2<#3>#4<#5>#6{\maxdeux<#1>{#2}<#3, #5>{\maxdeux<#3>{#4}<#5>{#6}}}
\def\annuleskip{\abovedisplayskip=0pt
\abovedisplayshortskip=0pt
\belowdisplayskip=0pt
\belowdisplayshortskip=0pt}
\setbeamercolor{alerted text}{fg=red}
%\setbeamercovered{highly dynamic}
\def\hbtow#1#2{\setbox0=\hbox{#2}\hbox to\wd0{\hss #1\hss}}
\abovedisplayskip=5pt minus 3pt
\abovedisplayshortskip=0pt
\belowdisplayskip=5pt minus 3pt
\belowdisplayshortskip=2pt minus 1pt
\endinput

59
latex/yslistings.tex Fichier normal
Voir le fichier

@@ -0,0 +1,59 @@
\usepackage{listings}
\usepackage{lstautogobble}
\usepackage{fontawesome}
\newbox\codebreakbox
\setbox\codebreakbox=\hbox{\textcolor[gray]{.75}{\scriptsize\upshape\faChevronCircleRight}}
\lstset{upquote=true,basicstyle=\ttfamily\NoAutoSpacing, keepspaces=true, columns=fullflexible, showstringspaces=false, commentstyle=\slshape, mathescape=true, stepnumber = 1, numberstyle=\scriptsize, numbersep=10pt, firstnumber=auto, breaklines=true, breakatwhitespace=true, prebreak={\copy\codebreakbox}, postbreak={\copy\codebreakbox}, autogobble, includerangemarker=false}
\lstset{literate=
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
{à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
{ű}{{\H{u}}}1 {Ű}{{\H{U}}}1 {ő}{{\H{o}}}1 {Ő}{{\H{O}}}1
{ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
{}{{\euro}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1
{»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1
}
\lstdefinestyle{numbers}{numbers = left}
\lstdefinestyle{nonumbers}{numbers = none}
\let\nm\|
\lstdefinelanguage{mybash}[]{bash}
{ morekeywords={ls, stat}}
\lstdefinelanguage{mysql}[]{sql}
{ morekeywords={INTER}}
\lstdefinelanguage{mypython}[]{python}
{ morekeywords={yield, as}}
\def\|{\lstinline[language=mypython, name=inlinepython]|} %|
\def{\lstinline[language={[Objective]caml}, name=inlinecaml]°}
\def{\lstinline[language=mysql, name=inlinesql]§}
\def\>{\lstinline[language=mybash, name=inlineshell]>} %>
\lstnewenvironment{lstpython}[1][]{\leavevmode\lstset{language=mypython, frame=single, frameround=tttt, #1}}{}
\lstnewenvironment{lstcaml}[1][]{\leavevmode\lstset{language=[Objective]caml, frame=single, frameround=tttt, #1}}{}
\lstnewenvironment{lstsql}[1][]{\leavevmode\lstset{language=mysql, frame=single, frameround=tttt, #1}}{}
\lstnewenvironment{lstshell}[1][]{\leavevmode\lstset{language=mybash, frame=single, frameround=tttt, #1}}{}
\newcommand\lstinputcaml[1][]{\leavevmode\lstinputlisting[language={[Objective]caml}, frame=single, frameround=tttt, rangeprefix=(***\ , rangesuffix=\ ***), #1]}
\newcommand\lstinputpython[1][]{\leavevmode\lstinputlisting[language={mypython}, frame=single, frameround=tttt, rangeprefix=\#\#\#\ , rangesuffix=\ \#\#\#, #1]}
\newcommand\lstinputsql[1][]{\leavevmode\lstinputlisting[language={mysql}, frame=single, frameround=tttt, rangeprefix=---\ , rangesuffix=\ ---, #1]}
\lstdefinelanguage{algorithme}{%
morekeywords={Si, alors, TantQue, faire, PourChaque, FinSi, FinPour, FinTantQue, Fonction, Renvoyer, Sinon},
sensitive=true,
morestring=[b]",
morecomment=[s]{/*}{*/}
}
\lstnewenvironment{lstalgo}[1][]{\leavevmode\lstset{columns=fullflexible, basicstyle=\rmfamily\NoAutoSpacing, language=algorithme, frame=single, frameround=tttt, #1}}{}
\endinput

62
latex/yssymbols.tex Fichier normal
Voir le fichier

@@ -0,0 +1,62 @@
\let\lbr\lBrack %%% Crochet double ouvrant
\let\rbr\rBrack %%% Crochet double fermant
%% Ensembles, intervalles
\def\genint#1#2#3#4#5{\mathord{\left#1#4\mathbin{#3}#5\right#2}}
\def\iff{\genint[],}
\def\ifo{\genint[[,}
\def\ioo{\genint][,}
\def\iof{\genint]],}
\def\Iff{\genint\lbr\rbr,}
\def\Ifo{\genint\lbr\lbr,}
\def\Ioo{\genint\rbr\lbr,}
\def\Iof{\genint\rbr\rbr,}
\def\R{\mathbb{R}}
\def\N{\mathbb{N}}
\def\Z{\mathbb{Z}}
\def\C{\mathbb{C}}
\def\diff{\mathrm d}
\def\enstq#1#2{\left\{ #1 \ \middle|\ #2\right\}}
\def\prive{\setminus}
\let\vec\overrightarrow
\AtBeginDocument{
\let\leq\leqslant
\let\geq\geqslant
\let\subset\subseteq
\let\supset\supseteq
\let\inter\cap
\let\union\cup
\let\epsilon\varepsilon
\let\kappa\varkappa
\let\phi\varphi
}
\def\ceil#1{\left\lceil#1\right\rceil}
\def\floor#1{\left\lfloor#1\right\rfloor}
\def\i{\mathrm{i}}
\def\dom{\mathcal D}
\def\sem#1#2{{\mathcal {V}}_{#2}(#1)}
\def\metab#1{\ensuremath{\langle #1\rangle}}
\def\metasyn#1{\metab{\tmit{#1}}}
\newenvironment{specification}{\vskip-\lastskip\ \par\begin{mdframed}[skipbelow=1ex]\begin{description}}{\end{description}\end{mdframed}}
\newenvironment{schema}[2]{\vskip-\lastskip\ \par\begin{mdframed}[skipbelow=1ex]\hfill Table \textbf{\sffamily #1}\hfill Clé primaire \textbf{\sffamily #2}\hfill \null\begin{description}}{\end{description}\end{mdframed}}
\def\nsql#1{\textbf{\sffamily #1}}
\def\V{\mathup{V}}
\def\F{\mathup{F}}
\let\textterm\texttt
\def\auto{\mathcal A}
\def\lang#1{\mathscr L\left(#1\right)}
\let\peuttrans\rightsquigarrow
\def\enspart#1{\mathscr P\left(#1\right)}
\endinput

68
latex/ystheorem.tex Fichier normal
Voir le fichier

@@ -0,0 +1,68 @@
\@ifundefined{ys@beamer}{
\usepackage[thmmarks, hyperref, amsmath]{ntheorem}
\newtheoremstyle{breakindent}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\theorem@separator}\hbox{\strut}}}]\hspace*{\parindent}}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\ (##3)\theorem@separator}\hbox{\strut}}}]\hspace*{\parindent}}
\newtheoremstyle{nonumberbreakindent}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\theorem@separator}\hbox{\strut}}}]\hspace*{\parindent}}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ (##3)\theorem@separator}\hbox{\strut}}}]\hspace*{\parindent}}
\newtheoremstyle{demo}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\theorem@separator}\hbox{\strut}}}]\hspace*{\parindent}}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\ ##3\theorem@separator}\hbox{\strut}}}]\hspace*{\parindent}}
\newtheoremstyle{nonumberdemo}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\theorem@separator}\hbox{\strut}}}]\hspace*{\parindent}}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##3\theorem@separator}\hbox{\strut}}}]\hspace*{\parindent}}
\def\rappelnumthm{{\tiny \raisebox{.25ex}{\thetheorem }}}
\theoremstyle{breakindent}
\theorembodyfont{\upshape}
\theoremseparator{. }
\theoremsymbol{\hbox{\hspace{2em}\rappelnumthm$\blacksquare$}}
\newtheorem{theorem}[equation]{Th\'eor\`eme}
\newtheorem{lemma}[equation]{Lemme}
\newtheorem{corollary}[equation]{Corolaire}
\theoremsymbol{\hbox{\hspace{2em}\rappelnumthm$\blacktriangleleft$}}
\newtheorem{definition}[equation]{D\'efinition}
\newtheorem{invariant}[equation]{Invariant}
\theoremheaderfont{\slshape}
\makeatletter
\theoremstyle{demo}
\def\refdem#1{\gdef\numerothm{\ref{#1}}\numerothm}
\def\rappelnumdem{\@ifundefined{numerothm}{}{{\tiny \raisebox{.25ex}{D\'em. de \numerothm\ }}\global\let\numerothm\relax}}
\theoremsymbol{\hbox{\hspace{2em}\rappelnumdem$\square$}}
\newtheorem*{proof}{D\'emonstration}
\theoremsymbol{\hbox{\hspace{2em}\rappelnumthm$\vartriangleleft$}}
\theoremstyle{breakindent}
\newtheorem{example}[equation]{Exemple}
\newtheorem{exo}[equation]{Exercice}
\newtheorem{remark}[equation]{Remarque}
\theoremsymbol{}
\theoremstyle{plain}
}{}
\endinput

86
latex/ystikz.tex Fichier normal
Voir le fichier

@@ -0,0 +1,86 @@
\ifluatex
\def\pgfsysdriver{pgfsys-luatex.def}
\else
\def\pgfsysdriver{pgfsys-xetex.def}
\fi
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations}
\usetikzlibrary{graphs}
\usetikzlibrary{trees}
\usetikzlibrary{babel}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{automata}
\ifluatex
\usetikzlibrary{graphdrawing}
\usegdlibrary{layered, force}
\fi
\usepackage[external]{forest}
%\tikzexternalize
\forestset{%
default preamble={
for tree={
circle,
draw,
inner sep=0pt,
minimum size=.5cm,
font=\scriptsize,
edge=->,
anchor=north
}
},
ssarbre/.style={isosceles triangle, draw, shape border rotate=90, minimum size=.7cm, child anchor=apex, anchor=apex}
}
\tikzstyle{basevertex} = [circle,
inner sep=0pt,
minimum size=.5cm,
font=\scriptsize]
\tikzstyle{vertex} = [basevertex, draw]
\tikzstyle{dotvertex} = [vertex]
\tikzset{graphs/every graph/.style={nodes={vertex},
edges={font=\scriptsize}}}
\tikzstyle{dotedgelbl} = [font=\scriptsize]
\tikzstyle{invisiblevertex} = [inner sep = 0pt, outer sep = 0pt, minimum size = 0pt]
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\usepackage[inputdir=./_build/]{dot2texi}
%%% https://tex.stackexchange.com/a/26386/103608
\usetikzlibrary{intersections}
\tikzset{
use path for main/.code={%
\tikz@addmode{%
\expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname
}%
},
use path for actions/.code={%
\expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}%
},
use path/.style={%
use path for main=#1,
use path for actions=#1,
}
}
%%%/
%%% https://tex.stackexchange.com/questions/6135/how-to-make-beamer-overlays-with-tikz-node#6155
%%% voir aussi https://tex.stackexchange.com/questions/99119/beamer-problematic-use-of-visible-and-only-in-combination-with-tikz-to-draw-a#99122
\tikzset{onslide/.code args={<#1>#2}{%
\only<#1>{\pgfkeysalso{#2}}
}}
\endinput

114
ocaml/affichage_auto.ml Fichier normal
Voir le fichier

@@ -0,0 +1,114 @@
#require "unix";;
module Affichage =
struct
let s_o_c a = if a = '"' then
"\\\\guill"
else if a = '\\' then
"\\\\ligne"
else if a = ' ' then
"\\\\espace"
else
String.make 1 a;;
let s_o_l a =
let lettre = s_o_c a
in "\"" ^ lettre ^ "\"";;
let s_o_m (a, n) =
let lettre = s_o_c a in
"\"$\\text{" ^ lettre ^ "}_{" ^ (string_of_int n) ^ "}$\"";;
let dot_auto print string_of_lettre auto =
let lien = "->" in
print ("digraph G {\n");
for x = 0 to auto.nQ - 1 do
print ((string_of_int x) ^ "[style=\"state");
if List.mem x auto.i then
print ",initial";
if List.mem x auto.f then
print ",accepting";
print ("\", label=\"" ^ (string_of_int x) ^ "\"];\n")
done;
List.iter (
fun (q, a, q') ->
print ((string_of_int q) ^ lien ^ (string_of_int q'));
print (" [label=" ^ (string_of_lettre a) ^ "]");
print ";\n"
)
auto.t;
print "}\n";;
let auto_to_file fn string_of_lettre auto =
let os = open_out fn in
let print = output_string os in
print "\\documentclass[tikz]{standalone}\n";
print "\\usetikzlibrary{automata, positioning, shapes, snakes, arrows}\n";
print "\\usepackage{dot2texi, amsmath}\n";
print "\\def\\guill{\"}\n\\def\\ligne{\\textbackslash\\textbackslash}\n\\def\\espace{\\textvisiblespace}\n";
print "\\begin{document}\n";
print "\\begin{tikzpicture}[scale=.75,shorten >=1pt,node distance=1cm,auto, initial text={}]\n";
print "\\begin{dot2tex}[tikz, codeonly, styleonly, options={-t raw}]\n";
dot_auto (output_string os) string_of_lettre auto;
print "\\end{dot2tex}\n";
(*flush os;
let fd_pipe_exit, fd_pipe_input = Unix.pipe () in
let outch_input = Unix.out_channel_of_descr fd_pipe_input in
let pid = Unix.create_process "dot2tex" [|"-f"; "tikz"; "-t"; "raw"; "--codeonly"; "--styleonly"|] (Unix.descr_of_out_channel os) fd_pipe_input Unix.stderr
in
dot_auto (output_string outch_input) string_of_lettre auto;
flush outch_input;
ignore (Unix.waitpid [Unix.WNOHANG] pid);
flush os;*)
print "\\end{tikzpicture}\n";
print "\\end{document}";
close_out os;;
let run wait cmd =
if wait then
ignore (Unix.system cmd)
else
ignore (Unix.open_process cmd);;
let rundot fn =
let bn = try Filename.chop_extension fn with Invalid_argument _ -> fn in
let pdfn = bn^".pdf" in
run true ("latexmk -xelatex -cd -shell-escape " ^ (Filename.quote fn));
pdfn;;
let openPDF wait fn =
run wait ("xdg-open " ^ (Filename.quote fn));;
let vizgraph wait fn =
let pdfn = rundot fn in
openPDF wait pdfn;;
let rec string_of_regexp sol = function
| Vide -> ""
| Epsilon -> "ε"
| Lettre(x) -> sol x
| Union([]) -> ""
| Union([x]) -> string_of_regexp sol x
| Union(le) -> "(" ^ (String.concat "|" (List.map (fun x -> string_of_regexp sol x) le)) ^ ")"
| Concat(le) -> String.concat "" (List.map (fun x -> string_of_regexp sol x) le)
| Etoile(x) -> (string_of_regexp sol x)^"*";;
end
let string_of_char = String.make 1;;
let string_of_charint (a, n) = (String.make 1 a) ^ (string_of_int n);;
let string_of_regexp = Affichage.string_of_regexp string_of_char;;
let string_of_regexp_marques = Affichage.string_of_regexp string_of_charint;;
let afficher_auto a = let fn = (Filename.temp_file "auto" ".tex") in
Affichage.auto_to_file fn Affichage.s_o_l a;
Affichage.vizgraph false fn;;
let afficher_auto_marques a = let fn = (Filename.temp_file "auto" ".tex") in
Affichage.auto_to_file fn Affichage.s_o_m a;
Affichage.vizgraph false fn;;
let string_of_list f l = "[" ^ (String.concat "; " (List.map f l)) ^"]";;

63
ocaml/affichage_graphe.ml Fichier normal
Voir le fichier

@@ -0,0 +1,63 @@
#load "unix.cma";;
(* graphe_to_dot génère la représentation dot d'un graphe orienté ou non avec
les infos issues de l'algo de Dijkstra. fn est le nom du fichier dans lequel on écrit
(recommandé : "/tmp/quelquechose.dot")
vizgraph fn lance la compilation d'un fichier dot en un PDF puis affiche ce PDF *)
let graphe_to_dot fn oriente graphe marques estimations parents =
let os = open_out fn in
let print = output_string os in
if oriente then print "di";
print "graph {\n";
print "rankdir=\"LR\";\n";
for x = 0 to Array.length graphe - 1 do
print (string_of_int x);
print "[label=\"";
if marques.(x) then print "*";
print (string_of_int x);
print " (";
if estimations.(x) = -1 then
print ""
else
print (string_of_int estimations.(x));
print ")\"];\n";
List.iter
(fun (y, w) -> if x < y || oriente then
begin
print (string_of_int x);
if oriente then print " -> " else print "--";
print (string_of_int y);
print "[label=\"";
print (string_of_int w);
print "\" ";
if parents.(y) = x || (not oriente && parents.(x) = y) then
print ",color=\"#FF0000\", penwidth=\"3\"";
print "];\n"
end
)
graphe.(x)
done;
print "}";
close_out os;;
let run wait cmd =
if wait then
ignore (Unix.system cmd)
else
ignore (Unix.open_process cmd);;
let rundot fn =
let bn = try Filename.chop_extension fn with Invalid_argument _ -> fn in
let pdfn = bn^".pdf" in
run true ("dot -Tpdf " ^ (Filename.quote fn) ^ " -o " ^ (Filename.quote pdfn));
pdfn;;
let openPDF wait fn =
run wait ("evince " ^ (Filename.quote fn));;
let vizgraph wait fn =
let pdfn = rundot fn in
openPDF wait pdfn;;

65
python/afficher_graphe.py Fichier normal
Voir le fichier

@@ -0,0 +1,65 @@
## Export dot
# La fonction importante est afficher_graphe (les autres sont auxiliaires)
# afficher_graphe(graphe, oriente, wait, distances=None, parents=None, bfn=None)
# graphe est une matrice qui représente un graphe pondéré comme ci-dessous :
# c'est une liste de listes Python ; l'absence d'arc est dénotée par un None
# orienté : True si le graphe est orienté, False sinon (la matrice graphe doit alors ^etre symétrique)
# wait : True s'il faut suspendre le programme jusqu'à ce que la fen^etre de visu soit fermée
# (pratique si on insère la visu dans la boucle de Dijkstra : on fige étape par étape)
# marques, distance, parents : comme dans Dijsktra ; si absent ou None : ne sera pas pris en compte
# bfn : le nom de fichier à utiliser ; si absent, un fichier temporaire sera utilisé.
def export(graphe, oriente, fn, marques=None, distances=None, parents=None) :
f = open(fn, "w")
if oriente :
print("digraph {", file = f)
lien = " -> "
else :
print("graph {", file = f)
lien = " -- "
print("""rankdir="LR";""", file=f)
for noeud in range(taille(graphe)) : # énumération des noeuds
label = str(noeud)
if marques != None and marques[noeud] :
label += "*"
if distances != None :
label += " ("
if distances[noeud] == PlusInfty :
label += "∞)"
else :
label += str(distances[noeud]) + ")"
print(str(noeud) + '[label="' + label + '"];', file = f)
for origine in range(0, taille(graphe)) : # énumérationd des arcs
for arrivee in range(0, taille(graphe)) :
if (oriente or origine < arrivee) and arc(graphe, origine, arrivee) :
if parents != None and parents[arrivee] == origine or not oriente and parents[origine] == arrivee :
style = ", penwidth=2, color=red"
else :
style = ""
print(str(origine) + lien + str(arrivee) + '[label="' + str(poids(graphe, origine, arrivee)) + '"' + style + "];", file=f)
print("}", file=f)
f.close()
import subprocess
def dot(fn_in, fn_out) :
"""Lance le programme dot sur le fichier fn_in, en lui demandant de produire le fichier fn_out.
Ne fonctionne que si le programme dot est installé sur la machine !!"""
subprocess.call(["dot", "-Tpdf", '-o'+fn_out+'', fn_in])
def evince(fn, wait=False) :
"""Lance le visualiseur PDF evince sur le fichier fn, et n'attend pas que celui-ci termine son exécution.
Ne fonctionne que si evince est installé."""
evince = subprocess.Popen(["evince", fn])
if wait :
evince.wait()
import tempfile
def afficher_graphe(graphe, oriente, wait, marques=None, distances=None, parents=None, bfn=None) :
if bfn == None :
bfn = tempfile.mktemp()
export(graphe, oriente, bfn+".dot", marques, distances, parents)
dot(bfn+".dot", bfn+".pdf")
evince(bfn+".pdf", wait)