expr= '(x1 & x2 | x3) == ( (x1 & x2 ) | x3)'; /// \sleftarrow{\normalfont expression is true ?} n=size(strindex(expr,'x'),'*') /// \sleftarrow {\begin{minipage}[t]{6cm}{\nf{}number of occurence of \verb+'x'+ in string\\ \verb+expr+. \verb+size+ with option \verb+'*'+ returns product of matrix dimensions} \end{minipage}} nv=0; for i=1:n if grep(expr,'x'+string(i))<>[] then /// \sleftarrow{\normalfont are \verb+x1,x2,...+ present in \verb+expr+ ?} nv=nv+1; end end nv /// \sleftarrow{\normalfont number of \verb+xi+ variables in \verb+expr+ } for i=1:nv expr=strsubst(expr,'x'+string(i),'x(:,'+string(i)+')'); end expr /// \sleftarrow{\normalfont substitution of \verb+xi+ by \verb+x(:,i)+ in \verb+expr+ {for} \verb+i=1:nv+} n=nv ; /// \sleftarrow{\normalfont \verb+n+ is the number of \verb+xi+ variables occuring in \verb+expr+} T=[1;0]; x=ones(2^n,n); for i=1:n x(:,i) = ones(2^(i-1),1).*.(T.*.ones(2^(n-i),1)); end x = (x > 0) /// \sleftarrow{\normalfont a matrix giving all the possible boolean values {for} \verb+n+ variables } execstr('rep=('+expr+')'); /// \sleftarrow {\begin{minipage}[t]{6cm}{\nf{}all the possible values {for} \verb+expr+ (we build a Scilab expressions and call the interpreter to evaluate it)} \end{minipage}} and(rep) /// \sleftarrow{\normalfont is \verb+expr+ always true ? all the entries of \verb+rep+ must be true }