2
$\begingroup$

I am writing a piece of Matlab 16 code (see below) to determine the monotone Boolean functions for a certain number of variables. The code works for variable numbers 0, 1, and 2 but fails to provide the correct number of monotone functions for variable numbers 3 and higher. I obtain 21 instead of 20.

I am following the description presented at http://www.mathpages.com/home/kmath094.htm

clear all;
clc

S{1} = '0';
S{2} = '1';

for k=1:3
    cnt = 0;
    for j=1:numel(S)
        for k=j:numel(S)
            cnt = cnt + 1;
            J{cnt} = strcat(S{j},S{k});
        end
    end
    clearvars S;
    S = J;
end 

Note that the vector S should provide each monotonic Boolean function. For $k=3$, I obtain 21 instead of the 20 I should be obtaining.

Although this may seem like a programming question at its root, I suspect that I am misunderstanding the description presented on the aforementioned webpage which is translating into an error in the code. Although I welcome any corrections to the code, I am more concerned with correcting my understanding of the approach.

Thank you!

1 Answers 1

2

The problem, as you must have noticed, comes with $00110101$, which is obtained by concatenating $0011$ and $0101$. This contravenes the rules, though, because $0011 \vee 0101 = 0111 \neq 0101$. Note that

a string Y cannot absorb X if Y is numerically less than X,

is only a necessary condition for adjoining to be possible.

Fixing the code requires testing the "absorption." Here's what I did:

S = {'0', '1'};

for n = 1:3
  cnt = 0;
  J = {};
  for m = 1:numel(S)
    bm = bin2dec(S{m});
    for k = m:numel(S)
      bk = bin2dec(S{k});
      if bitor(bm, bk) == bk
        cnt = cnt + 1;
        J{cnt} = strcat(S{m},S{k}); %#ok
      end
    end
  end
  S = J;
end

The monotone function count for n=6 took about 7 minutes to compute. It agrees with the one from the page you linked.

  • 0
    Fabio, Thank you very much. I did notice that that was the value which did not agree with the website's solution but I missed the absorption statement.2017-01-03