function fillQuartenary(setList) {
setList(oddFn);
setList(evenFn);
for (let i = 0; i < 2 ** 4; i++) {
for (let fn of [
andFn,
orFn,
countEq1,
countNeq1,
countLeq1,
countLeq2,
countEq02,
countNeq02,
countEq03,
countNeq03,
countEq12,
countNeq12
]) {
setList(applyNegations(fn, i));
}
}
for (let i = 0; i < 2 ** 4; i++) {
let bitCount = countBits(i);
if (bitCount < 2 || (bitCount === 2 && i % 2 === 0)) {
for (let fn of [eqFn, neqFn, countEq2, countNeq2]) {
setList(applyNegations(fn, i));
}
}
}
for (let order of permutations(_.range(4))) {
for (let i = 0; i < 2 ** 3; i++) {
for (let fn of [muxAnd, muxOr]) {
setList(permuteFn(applyNegations(fn, i << 1), order));
}
}
for (let i = 0; i < 2 ** 2; i++) {
for (let fn of [muxEq]) {
setList(permuteFn(applyNegations(fn, i << 1), order));
}
}
if (order[0] < order[1]) {
for (let i = 0; i < 2 ** 4; i++) {
for (let fn of [
andOrAnd,
orAndOr,
andOrEq,
andEqAnd,
andEqOr,
andEquivImpl,
andNEquivImpl,
orEquivImpl,
orNEquivImpl,
equivImplAnd,
equivImplOr,
nEquivImplAnd,
nEquivImplOr,
equivImplEq
]) {
setList(permuteFn(applyNegations(fn, i), order));
}
}
for (let i = 0; i < 2 ** 4; i += 2) {
for (let fn of [eqAndOr, eqOrAnd, eqAndEq, eqEquivImpl, eqNEquivImpl]) {
setList(permuteFn(applyNegations(fn, i), order));
}
}
}
if (order[2] < order[3]) {
for (let i = 0; i < 2 ** 4; i++) {
for (let fn of [andCMux, orCMux]) {
setList(permuteFn(applyNegations(fn, i), order));
}
}
for (let i = 0; i < 2 ** 3; i++) {
setList(permuteFn(applyNegations(eqCMux, i), order));
}
}
if (order[0] < order[1] && order[2] < order[3]) {
for (let i = 0; i < 2 ** 3; i++) {
for (let fn of [orOfAndEq, andOfOrEq, eqCEquivImpl, eqCNEquivImpl]) {
setList(permuteFn(applyNegations(fn, i), order));
}
}
for (let i = 0; i < 2 ** 4; i++) {
for (let fn of [
orAnd3,
andOr3,
andEq3,
andNeq3,
andCountEq1,
andCountNeq1,
orCountEq1,
orCountNeq1,
andCountLeq1,
andCountGeq2,
andMux,
orMux,
andCEquivImpl,
andCNEquivImpl,
orCEquivImpl,
orCNEquivImpl
]) {
setList(permuteFn(applyNegations(fn, i), order));
}
}
for (let i = 0; i < 2 ** 4; i += 2) {
setList(permuteFn(applyNegations(eqAnd3, i), order));
setList(permuteFn(applyNegations(eqOr3, i), order));
setList(permuteFn(applyNegations(eqCountEq1, i), order));
setList(permuteFn(applyNegations(eqCountNeq1, i), order));
setList(permuteFn(applyNegations(eqCountLeq1, i), order));
setList(permuteFn(applyNegations(eqMux, i), order));
}
for (let i = 0; i < 2 ** 2; i++) {
setList(permuteFn(applyNegations(andOdd3, i), order));
setList(permuteFn(applyNegations(andEven3, i), order));
setList(permuteFn(applyNegations(xorEq3, i << 2), order));
setList(permuteFn(applyNegations(xorNeq3, i << 2), order));
}
}
}
// A is fixed, all others permute
for (let order of cycle([1, 2, 3])) {
order = [0, ...order];
for (let i = 0; i < 2 ** 4; i++) {
for (let fn of [andOfOrs, orOfAnds, eqOfAnds, neqOfAnds]) {
setList(permuteFn(applyNegations(fn, i), order));
}
}
for (let i of [0, 0b0010, 0b1000, 0b1010]) {
setList(permuteFn(applyNegations(andOfEqs, i), order));
setList(permuteFn(applyNegations(orOfEqs, i), order));
}
}
for (let order of cycle(_.range(4))) {
for (let i = 0; i < 2 ** 4; i++) {
for (let fn of [
and3Or,
or3And,
and3Eq,
countEq1And,
countNeq1Or,
countEq1Or,
countNeq1And,
countEq1Eq,
countLeq1And,
countLeq1Or
]) {
setList(permuteFn(applyNegations(fn, i), order));
}
if (countBits(i % 2 ** 3) <= 1) {
for (let fn of [eq3And, neq3Or, eq3Or, neq3And, eq3Xor]) {
setList(permuteFn(applyNegations(fn, i), order));
}
}
}
for (let i = 0; i < 2 ** 3; i++) {
setList(permuteFn(applyNegations(countLeq1Eq, i), order));
}
for (let i = 0; i < 2 ** 2; i++) {
for (let fn of [odd3And, odd3Or]) {
setList(permuteFn(applyNegations(fn, i << 2), order));
}
}
}
}