function [A,B,chf,chll]=lois_exhaustives_booleennes_deux % donne toutes les lois booléénnes agissant sur 2 booléens, avec expressions complètes % % ********************************************************* % [A,B,chf]=lois_exhaustives_booleennes_deux % * Variables d'entrée % * Aucune % * Variables de sortie : % * A : tabeau de logiques. Les 2 premières colonnes contiennent toutes % les valeurs possibles des booléens. Les dernières contiennent toutes % les lois possibles booléennes. % * B : tableau (6,18). Les 2 premières colonnes contiennent toutes % les valeurs possibles des booléens. Les dernières contiennent toutes % les lois possibles booléennes, construites explicitement. % l'avant dernière ligne de B contient les indices par rapport aux lois de A % la dernière ligne de B contient les indices par rapport aux contraires des % lois de A % * chf : lois discrètes explicites de B sous forme de fonction % anonymes. % * Variables de sortie optionnelle : % * chfll : lois discrètes explicites de B sous forme de chaîne LaTeX. % % % ************ Fonctions auxiliaires utilisées ************ % % produit_cartesien % % ********************************************************* % % 2020 by Jérôme BASTIEN % Université Claude Bernard Lyon I, Polytech, Laboratoire LIBM, Villeurbanne % E-Mail : jerome.bastien@univ-lyon1.fr A=lois_booleennes_exhaustives(2); %b=produit_cartesien({[0,1],[0,1],[0,1]}); b=produit_cartesien({[1,0],[1,0],[1,0]}); p=size(b,1); chl=cell(1,p+8); chf=chl; for i=1:p chllo=[]; if b(i,2) chflo='and('; else chflo='or('; end if b(i,1) chflo=[chflo,'x,']; chllo=[chllo,'P']; else chflo=[chflo,'~x,']; chllo=[chllo,' (\neg P)']; end if b(i,2) chllo=[chllo,'\wedge ']; else chllo=[chllo,'\vee ']; end if b(i,3) chflo=[chflo,'y)']; chllo=[chllo,'Q']; else chflo=[chflo,'~y),']; chllo=[chllo,'(\neg Q)']; end chf{i}=eval(['@(x,y)',chflo]); chl{i}=chllo; end i=p+1; chf{i}=@(x,y) x; chl{i}='P'; i=p+2; chf{i}=@(x,y) y; chl{i}='Q'; i=p+3; chf{i}=@(x,y) ~x; chl{i}='\neg P'; i=p+4; chf{i}=@(x,y) ~y; chl{i}='\neg Q'; i=p+5; chf{i}=@(x,y) xor(x,y); chl{i}='P\oplus Q'; i=p+6; chf{i}=@(x,y) and(or(y,~x),or(x,~y)); chl{i}='P\Longleftrightarrow Q'; i=p+7; chf{i}=@(x,y) and(x,~x); chl{i}='\text{F}'; i=p+8; chf{i}=@(x,y) or(x,~x); chl{i}='\text{V}'; C=zeros(4,2+8+8); C(:,1:2)=A(:,1:2); for i=1:8+8 C(:,i+2)=feval(chf{i},C(:,1),C(:,2)); end Cl=C(:,3:end); Al=A(:,3:end); Aln=~A(:,3:end); [tf,loc]=ismember((Cl).',(Al).', 'rows'); [tf,locn]=ismember((Cl).',(Aln).', 'rows'); loc=loc.'; locn=locn.'; if ~(length(loc)==16&length(locn)==16) error('toutes les lois n''ont pas été identifiées'); end A=logical(A); B=zeros(6,18); B(1:4,:)=C; B(end-1:end,1:2)=NaN; B(end-1,3:end)=loc; B(end,3:end)=locn; if nargout>=3 chll=chl; end