From d65f05e524b6dddf4c57dd93adda6b2cb57f1969 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 26 Sep 2023 20:04:16 +0000 Subject: profsio (26sep23) git-svn-id: svn://tug.org/texlive/trunk@68374 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/profsio/ProfSio.sty | 132 +++++++++++++++++++++++- 1 file changed, 129 insertions(+), 3 deletions(-) (limited to 'Master/texmf-dist/tex/latex/profsio') diff --git a/Master/texmf-dist/tex/latex/profsio/ProfSio.sty b/Master/texmf-dist/tex/latex/profsio/ProfSio.sty index 7fc09269a8a..c492ec141a1 100644 --- a/Master/texmf-dist/tex/latex/profsio/ProfSio.sty +++ b/Master/texmf-dist/tex/latex/profsio/ProfSio.sty @@ -3,7 +3,8 @@ % : Luatruthtable from Chetan Shirore and Dr. Ajit Kumar https://ctan.org/pkg/luatruthtable \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{ProfSio}[2023/09/20 0.1.6 Pour les enseignants de Maths en BTS SIO] +\ProvidesPackage{ProfSio}[2023/09/25 0.1.7 Pour les enseignants de Maths en BTS SIO] +%0.1.7 Ajout des simplifications booléennes d'expressions classiques %0.1.6 Correction dans les simplifications de Karnaugh + Possibilité de travailler avec le contraire %0.1.5 Simplification d'expressions booléennes (par Karnaugh) %0.1.4 Possibilité de remplir une table de Karnaugh sans virgule @@ -22,6 +23,8 @@ \RequirePackage{xintexpr} %------Librairies \usetikzlibrary{positioning,decorations.pathreplacing,decorations.markings,arrows,arrows.meta,calc,babel,shapes,shapes.geometric} +%------Divers +\def\§{\mkern1.5mu\relax} %------Graphe MPM \defKV[MPM]{% @@ -1278,7 +1281,6 @@ end \fi %------Simplifications booléennes - \defKV[SimplifKngh]{% Couleurs=\def\SimplifKnghCoul{#1},% Variables=\def\SimplifKnghVar{#1} @@ -1331,7 +1333,7 @@ end }% \ifboolKV[SimplifKngh]{Espace}% {% - \def\tmp@kngh@space{\,}% + \def\tmp@kngh@space{\§}% }% {% \def\tmp@kngh@space{}% @@ -1603,4 +1605,128 @@ end }% } +\ExplSyntaxOn +\NewExpandableDocumentCommand{\KnghBourrageZeros}{m} +{ + \int_compare:nT { #1 > 0 } + { + 0 \prg_replicate:nn { #1 - 1 } { 0 } + } +} +\ExplSyntaxOff + +\defKV[simplifbool]{% + Variables=\def\simplifboolvars{#1} +} + +\setKVdefault[simplifbool]{% + Variables={a/b/c},% + Enonce=true,% + Espace=true,% + Contraire=false +} + +\NewDocumentCommand\SimplificationBooleenne{ O{} m D<>{} }{%semble OK + \useKVdefault[simplifbool]% + \setKV[simplifbool]{#1}% + \setsepchar[.]{/}% + \readlist*\ListeVariablesKGH{\simplifboolvars}% + \itemtomacro\ListeVariablesKGH[1]{\VarTMPA}% + \itemtomacro\ListeVariablesKGH[2]{\VarTMPB}% + \itemtomacro\ListeVariablesKGH[3]{\VarTMPC}% + %gestion des espaces + \ifboolKV[simplifbool]{Espace}% + {% + \def\tmp@kngh@space{\§}% + }% + {% + \def\tmp@kngh@space{}% + }% + %énoncé + \StrSubstitute{#2}{\VarTMPA}{AA}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{\VarTMPB}{BB}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{\VarTMPC}{CC}[\knghenoncetransf]% + %\knghenoncetransf% + \StrSubstitute{\knghenoncetransf}{(AA)}{\VarTMPA}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(BB)}{\VarTMPB}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(CC)}{\VarTMPC}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*)}{\overline{\VarTMPA}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(BB*}{\overline{\VarTMPB}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(CC*)}{\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AABB)}{\VarTMPA\tmp@kngh@space\VarTMPB}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AACC*)}{\VarTMPA\tmp@kngh@space\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AABB*)}{\VarTMPA\tmp@kngh@space\overline{\VarTMPB}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*BB)}{\overline{\VarTMPA}\tmp@kngh@space\VarTMPB}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*CC*)}{\overline{\VarTMPA}\tmp@kngh@space\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*BB*)}{\overline{\VarTMPA}\tmp@kngh@space\overline{\VarTMPB}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AACC)}{\VarTMPA\tmp@kngh@space\VarTMPC}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*CC)}{\overline{\VarTMPA}\tmp@kngh@space\VarTMPC}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(BBCC)}{\VarTMPB\tmp@kngh@space\VarTMPC}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(BBCC*)}{\VarTMPB\tmp@kngh@space\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(BB*CC*)}{\overline{\VarTMPB}\tmp@kngh@space\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(BB*CC)}{\overline{\VarTMPB}\tmp@kngh@space\VarTMPC}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AABBCC)}{\VarTMPA\tmp@kngh@space\VarTMPB\tmp@kngh@space\VarTMPC}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AABBCC*)}{\VarTMPA\tmp@kngh@space\VarTMPB\tmp@kngh@space\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AABB*CC*)}{\VarTMPA\tmp@kngh@space\overline{\VarTMPB}\tmp@kngh@space\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AABB*CC)}{\VarTMPA\tmp@kngh@space\overline{\VarTMPB}\tmp@kngh@space\VarTMPC}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*BBCC)}{\overline{\VarTMPA}\tmp@kngh@space\VarTMPB\tmp@kngh@space\VarTMPC}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*BBCC*)}{\overline{\VarTMPA}\tmp@kngh@space\VarTMPB\tmp@kngh@space\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*BB*CC*)}{\overline{\VarTMPA}\tmp@kngh@space\overline{\VarTMPB}\tmp@kngh@space\overline{\VarTMPC}}[\knghenoncetransf]% + \StrSubstitute{\knghenoncetransf}{(AA*BB*CC)}{\overline{\VarTMPA}\tmp@kngh@space\overline{\VarTMPB}\tmp@kngh@space\VarTMPC}[\knghenoncetransf]% + %substitutions pour binaire + \StrSubstitute{#2}{\VarTMPA}{AA}[\knghbintransf]% + \StrSubstitute{\knghbintransf}{\VarTMPB}{BB}[\knghbintransf]% + \StrSubstitute{\knghbintransf}{\VarTMPC}{CC}[\knghbintransf]% + \xdef\knghbinres{00000000}% + %calculs pour 1 lettre + \IfSubStr{\knghbintransf}{(AA)}{\xdef\knghbinres{\inteval{\knghbinres+11110000}}}{}% + \IfSubStr{\knghbintransf}{(BB)}{\xdef\knghbinres{\inteval{\knghbinres+11001100}}}{}% + \IfSubStr{\knghbintransf}{(CC)}{\xdef\knghbinres{\inteval{\knghbinres+01100110}}}{}% + \IfSubStr{\knghbintransf}{(AA*)}{\xdef\knghbinres{\inteval{\knghbinres+00001111}}}{}% + \IfSubStr{\knghbintransf}{(BB*}{\xdef\knghbinres{\inteval{\knghbinres+00110011}}}{}% + \IfSubStr{\knghbintransf}{(CC*)}{\xdef\knghbinres{\inteval{\knghbinres+10011001}}}{}% + %calculs pour 2 lettres + \IfSubStr{\knghbintransf}{(AABB)}{\xdef\knghbinres{\inteval{\knghbinres+11000000}}}{}% + \IfSubStr{\knghbintransf}{(AACC*)}{\xdef\knghbinres{\inteval{\knghbinres+01100000}}}{}% + \IfSubStr{\knghbintransf}{(AABB*)}{\xdef\knghbinres{\inteval{\knghbinres+00110000}}}{}% + \IfSubStr{\knghbintransf}{(AA*BB)}{\xdef\knghbinres{\inteval{\knghbinres+00001100}}}{}% + \IfSubStr{\knghbintransf}{(AA*CC*)}{\xdef\knghbinres{\inteval{\knghbinres+00000110}}}{}% + \IfSubStr{\knghbintransf}{(AA*BB*)}{\xdef\knghbinres{\inteval{\knghbinres+00000011}}}{}% + \IfSubStr{\knghbintransf}{(AACC)}{\xdef\knghbinres{\inteval{\knghbinres+10010000}}}{}% + \IfSubStr{\knghbintransf}{(AA*CC)}{\xdef\knghbinres{\inteval{\knghbinres+00001001}}}{}% + \IfSubStr{\knghbintransf}{(BBCC)}{\xdef\knghbinres{\inteval{\knghbinres+10001000}}}{}% + \IfSubStr{\knghbintransf}{(BBCC*)}{\xdef\knghbinres{\inteval{\knghbinres+01000100}}}{}% + \IfSubStr{\knghbintransf}{(BB*CC*)}{\xdef\knghbinres{\inteval{\knghbinres+00100010}}}{}% + \IfSubStr{\knghbintransf}{(BB*CC)}{\xdef\knghbinres{\inteval{\knghbinres+00010001}}}{}% + %calculs pour 3 lettres + \IfSubStr{\knghbintransf}{(AABBCC)}{\xdef\knghbinres{\inteval{\knghbinres+10000000}}}{}% + \IfSubStr{\knghbintransf}{(AABBCC*)}{\xdef\knghbinres{\inteval{\knghbinres+01000000}}}{}% + \IfSubStr{\knghbintransf}{(AABB*CC*)}{\xdef\knghbinres{\inteval{\knghbinres+00100000}}}{}% + \IfSubStr{\knghbintransf}{(AABB*CC)}{\xdef\knghbinres{\inteval{\knghbinres+00010000}}}{}% + \IfSubStr{\knghbintransf}{(AA*BBCC)}{\xdef\knghbinres{\inteval{\knghbinres+00001000}}}{}% + \IfSubStr{\knghbintransf}{(AA*BBCC*)}{\xdef\knghbinres{\inteval{\knghbinres+00000100}}}{}% + \IfSubStr{\knghbintransf}{(AA*BB*CC*)}{\xdef\knghbinres{\inteval{\knghbinres+00000010}}}{}% + \IfSubStr{\knghbintransf}{(AA*BB*CC)}{\xdef\knghbinres{\inteval{\knghbinres+00000001}}}{}% + %on complète + \StrLen{\knghbinres}[\knghbinresnbchiffres] + \ifnum\knghbinresnbchiffres<8% + \xdef\nbz{\inteval{8-\knghbinresnbchiffres}}% + \xdef\knghbinres{\KnghBourrageZeros{\nbz}\knghbinres}% + \fi% + \xintFor* ##1 in {\xintSeq{2}{8}}\do{\StrSubstitute{\knghbinres}{##1}{1}[\knghbinres]}% + \ifboolKV[simplifbool]{Contraire}% + {% + \StrSubstitute{\knghbinres}{0}{2}[\knghbinres]% + \StrSubstitute{\knghbinres}{1}{0}[\knghbinres]% + \StrSubstitute{\knghbinres}{2}{1}[\knghbinres]% + }% + {}% + \ensuremath{% + \ifboolKV[simplifbool]{Enonce}{\ifboolKV[simplifbool]{Contraire}{\overline{\knghenoncetransf}}{\knghenoncetransf}=}{}% + \ifboolKV[simplifbool]{Espace}% + {\SimplificationKarnaugh[Variables={\simplifboolvars},Espace=true,#3]{\knghbinres}}% + {\SimplificationKarnaugh[Variables={\simplifboolvars},Espace=false,#3]{\knghbinres}}% + } +} + \endinput \ No newline at end of file -- cgit v1.2.3